Update go-whatsapp

This commit is contained in:
Tulir Asokan 2021-02-10 21:20:31 +02:00
parent e6045a3cf5
commit ba0ec021ba
5 changed files with 8 additions and 4 deletions

View file

@ -499,7 +499,7 @@ func (handler *CommandHandler) CommandReconnect(ce *CommandEvent) {
ce.User.SetSession(&sess) ce.User.SetSession(&sess)
} }
err = ce.User.Conn.Restore() err = ce.User.Conn.Restore(true)
if err == whatsapp.ErrInvalidSession { if err == whatsapp.ErrInvalidSession {
if ce.User.Session != nil { if ce.User.Session != nil {
ce.User.log.Debugln("Got invalid session error when reconnecting, but user has session. Retrying using RestoreWithSession()...") ce.User.log.Debugln("Got invalid session error when reconnecting, but user has session. Retrying using RestoreWithSession()...")

2
go.mod
View file

@ -16,4 +16,4 @@ require (
maunium.net/go/mautrix v0.8.2 maunium.net/go/mautrix v0.8.2
) )
replace github.com/Rhymen/go-whatsapp => github.com/tulir/go-whatsapp v0.3.20 replace github.com/Rhymen/go-whatsapp => github.com/tulir/go-whatsapp v0.3.21

2
go.sum
View file

@ -143,6 +143,8 @@ github.com/tulir/go-whatsapp v0.3.19 h1:76VtmcjKGX8MbfJN9NNi1f0IVmigTLUcxqE1VRco
github.com/tulir/go-whatsapp v0.3.19/go.mod h1:U5+sm33vrv3wz62YyRM/VS7q2ObXkxU4Xqj/3KOmN9o= github.com/tulir/go-whatsapp v0.3.19/go.mod h1:U5+sm33vrv3wz62YyRM/VS7q2ObXkxU4Xqj/3KOmN9o=
github.com/tulir/go-whatsapp v0.3.20 h1:nK92MgruqXwk+QlaAS39xhzHNbFvJIEgUIOUrN3i8Yc= github.com/tulir/go-whatsapp v0.3.20 h1:nK92MgruqXwk+QlaAS39xhzHNbFvJIEgUIOUrN3i8Yc=
github.com/tulir/go-whatsapp v0.3.20/go.mod h1:U5+sm33vrv3wz62YyRM/VS7q2ObXkxU4Xqj/3KOmN9o= github.com/tulir/go-whatsapp v0.3.20/go.mod h1:U5+sm33vrv3wz62YyRM/VS7q2ObXkxU4Xqj/3KOmN9o=
github.com/tulir/go-whatsapp v0.3.21 h1:2m7gUw4oHX4kIpMmP9VwCR7KEUK/PHhXLygPFGF9XfI=
github.com/tulir/go-whatsapp v0.3.21/go.mod h1:U5+sm33vrv3wz62YyRM/VS7q2ObXkxU4Xqj/3KOmN9o=
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=

View file

@ -201,7 +201,7 @@ func (prov *ProvisioningAPI) Reconnect(w http.ResponseWriter, r *http.Request) {
} }
user.log.Debugln("Restoring session for /reconnect") user.log.Debugln("Restoring session for /reconnect")
err = user.Conn.Restore() err = user.Conn.Restore(true)
user.log.Debugfln("Restore session for /reconnect responded with %v", err) user.log.Debugfln("Restore session for /reconnect responded with %v", err)
if err == whatsapp.ErrInvalidSession { if err == whatsapp.ErrInvalidSession {
if user.Session != nil { if user.Session != nil {

View file

@ -801,12 +801,14 @@ func (user *User) tryReconnect(msg string) {
} }
delay := baseDelay delay := baseDelay
conn := user.Conn conn := user.Conn
takeover := false
for user.ConnectionErrors <= user.bridge.Config.Bridge.MaxConnectionAttempts { for user.ConnectionErrors <= user.bridge.Config.Bridge.MaxConnectionAttempts {
if user.Conn != conn { if user.Conn != conn {
user.log.Debugln("Connection was recreated, aborting reconnection attempts") user.log.Debugln("Connection was recreated, aborting reconnection attempts")
return return
} }
err := conn.Restore() err := conn.Restore(takeover)
takeover = true
if err == nil { if err == nil {
user.ConnectionErrors = 0 user.ConnectionErrors = 0
if user.bridge.Config.Bridge.ReportConnectionRetry { if user.bridge.Config.Bridge.ReportConnectionRetry {