summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/Rhymen/go-whatsapp/session.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2019-06-13 22:37:31 +0200
committerWim <wim@42.be>2019-06-14 00:02:32 +0200
commitce7b749fd54be871ce62934fca7978b165809e87 (patch)
treea586345061cd3c48dd97dd81ac12141f716a212e /vendor/github.com/Rhymen/go-whatsapp/session.go
parent6617bd6609993ab70798647620dfbbcff523347e (diff)
downloadmatterbridge-msglm-ce7b749fd54be871ce62934fca7978b165809e87.tar.gz
matterbridge-msglm-ce7b749fd54be871ce62934fca7978b165809e87.tar.bz2
matterbridge-msglm-ce7b749fd54be871ce62934fca7978b165809e87.zip
Update github.com/Rhymen/go-whatsapp vendor. Fixes #843
Diffstat (limited to 'vendor/github.com/Rhymen/go-whatsapp/session.go')
-rw-r--r--vendor/github.com/Rhymen/go-whatsapp/session.go16
1 files changed, 9 insertions, 7 deletions
diff --git a/vendor/github.com/Rhymen/go-whatsapp/session.go b/vendor/github.com/Rhymen/go-whatsapp/session.go
index b769ef5a..3b9ba235 100644
--- a/vendor/github.com/Rhymen/go-whatsapp/session.go
+++ b/vendor/github.com/Rhymen/go-whatsapp/session.go
@@ -15,9 +15,12 @@ import (
"github.com/Rhymen/go-whatsapp/crypto/hkdf"
)
+//represents the WhatsAppWeb client version
+var waVersion = []int{0, 3, 3324}
+
/*
Session contains session individual information. To be able to resume the connection without scanning the qr code
-every time you should save the Session returned by Login and use RestoreSession the next time you want to login.
+every time you should save the Session returned by Login and use RestoreWithSession the next time you want to login.
Every successful created connection returns a new Session. The Session(ClientToken, ServerToken) is altered after
every re-login and should be saved every time.
*/
@@ -99,7 +102,7 @@ func (wac *Conn) SetClientName(long, short string) error {
/*
Login is the function that creates a new whatsapp session and logs you in. If you do not want to scan the qr code
-every time, you should save the returned session and use RestoreSession the next time. Login takes a writable channel
+every time, you should save the returned session and use RestoreWithSession the next time. Login takes a writable channel
as an parameter. This channel is used to push the data represented by the qr code back to the user. The received data
should be displayed as an qr code in a way you prefer. To print a qr code to console you can use:
github.com/Baozisoftware/qrcode-terminal-go Example login procedure:
@@ -148,8 +151,7 @@ func (wac *Conn) Login(qrChan chan<- string) (Session, error) {
}
session.ClientId = base64.StdEncoding.EncodeToString(clientId)
- //oldVersion=8691
- login := []interface{}{"admin", "init", []int{0, 3, 225}, []string{wac.longClientName, wac.shortClientName}, session.ClientId, true}
+ login := []interface{}{"admin", "init", waVersion, []string{wac.longClientName, wac.shortClientName}, session.ClientId, true}
loginChan, err := wac.writeJson(login)
if err != nil {
return session, fmt.Errorf("error writing login: %v\n", err)
@@ -272,7 +274,7 @@ func (wac *Conn) RestoreWithSession(session Session) (_ Session, err error) {
}
/*//TODO: GoDoc
-RestoreSession is the function that restores a given session. It will try to reestablish the connection to the
+RestoreWithSession is the function that restores a given session. It will try to reestablish the connection to the
WhatsAppWeb servers with the provided session. If it succeeds it will return a new session. This new session has to be
saved because the Client and Server-Token will change after every login. Logging in with old tokens is possible, but not
suggested. If so, a challenge has to be resolved which is just another possible point of failure.
@@ -303,7 +305,7 @@ func (wac *Conn) Restore() error {
wac.listener.Unlock()
//admin init
- init := []interface{}{"admin", "init", []int{0, 3, 225}, []string{wac.longClientName, wac.shortClientName}, wac.session.ClientId, true}
+ init := []interface{}{"admin", "init", waVersion, []string{wac.longClientName, wac.shortClientName}, wac.session.ClientId, true}
initChan, err := wac.writeJson(init)
if err != nil {
return fmt.Errorf("error writing admin init: %v\n", err)
@@ -338,7 +340,7 @@ func (wac *Conn) Restore() error {
return fmt.Errorf("error decoding s1 message: %v\n", err)
}
case <-time.After(wac.msgTimeout):
-
+
//check for an error message
select {
case r := <-loginChan: