summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/Rhymen/go-whatsapp/session.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/Rhymen/go-whatsapp/session.go')
-rw-r--r--vendor/github.com/Rhymen/go-whatsapp/session.go24
1 files changed, 19 insertions, 5 deletions
diff --git a/vendor/github.com/Rhymen/go-whatsapp/session.go b/vendor/github.com/Rhymen/go-whatsapp/session.go
index f026df7d..dc3acd57 100644
--- a/vendor/github.com/Rhymen/go-whatsapp/session.go
+++ b/vendor/github.com/Rhymen/go-whatsapp/session.go
@@ -18,7 +18,7 @@ import (
)
//represents the WhatsAppWeb client version
-var waVersion = []int{0, 4, 2080}
+var waVersion = []int{2, 2033, 7}
/*
Session contains session individual information. To be able to resume the connection without scanning the qr code
@@ -141,11 +141,11 @@ func CheckCurrentServerVersion() ([]int, error) {
SetClientName sets the long and short client names that are sent to WhatsApp when logging in and displayed in the
WhatsApp Web device list. As the values are only sent when logging in, changing them after logging in is not possible.
*/
-func (wac *Conn) SetClientName(long, short, version string) error {
+func (wac *Conn) SetClientName(long, short string) error {
if wac.session != nil && (wac.session.EncKey != nil || wac.session.MacKey != nil) {
return fmt.Errorf("cannot change client name after logging in")
}
- wac.longClientName, wac.shortClientName, wac.clientVersion = long, short, version
+ wac.longClientName, wac.shortClientName = long, short
return nil
}
@@ -231,7 +231,12 @@ func (wac *Conn) Login(qrChan chan<- string) (Session, error) {
return session, fmt.Errorf("error decoding login resp: %v\n", err)
}
- ref := resp["ref"].(string)
+ var ref string
+ if rref, ok := resp["ref"].(string); ok {
+ ref = rref
+ } else {
+ return session, fmt.Errorf("error decoding login resp: invalid resp['ref']\n")
+ }
priv, pub, err := curve25519.GenerateKey()
if err != nil {
@@ -390,9 +395,11 @@ func (wac *Conn) Restore() error {
}
if int(resp["status"].(float64)) != 200 {
+ wac.timeTag = ""
return fmt.Errorf("init responded with %d", resp["status"])
}
case <-time.After(wac.msgTimeout):
+ wac.timeTag = ""
return fmt.Errorf("restore session init timed out")
}
@@ -401,10 +408,11 @@ func (wac *Conn) Restore() error {
select {
case r1 := <-s1:
if err := json.Unmarshal([]byte(r1), &connResp); err != nil {
+ wac.timeTag = ""
return fmt.Errorf("error decoding s1 message: %v\n", err)
}
case <-time.After(wac.msgTimeout):
-
+ wac.timeTag = ""
//check for an error message
select {
case r := <-loginChan:
@@ -429,15 +437,18 @@ func (wac *Conn) Restore() error {
wac.listener.Unlock()
if err := wac.resolveChallenge(connResp[1].(map[string]interface{})["challenge"].(string)); err != nil {
+ wac.timeTag = ""
return fmt.Errorf("error resolving challenge: %v\n", err)
}
select {
case r := <-s2:
if err := json.Unmarshal([]byte(r), &connResp); err != nil {
+ wac.timeTag = ""
return fmt.Errorf("error decoding s2 message: %v\n", err)
}
case <-time.After(wac.msgTimeout):
+ wac.timeTag = ""
return fmt.Errorf("restore session challenge timed out")
}
}
@@ -447,13 +458,16 @@ func (wac *Conn) Restore() error {
case r := <-loginChan:
var resp map[string]interface{}
if err = json.Unmarshal([]byte(r), &resp); err != nil {
+ wac.timeTag = ""
return fmt.Errorf("error decoding login connResp: %v\n", err)
}
if int(resp["status"].(float64)) != 200 {
+ wac.timeTag = ""
return fmt.Errorf("admin login responded with %d", resp["status"])
}
case <-time.After(wac.msgTimeout):
+ wac.timeTag = ""
return fmt.Errorf("restore session login timed out")
}