summaryrefslogtreecommitdiffstats
path: root/vendor/go.mau.fi/whatsmeow/connectionevents.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2022-03-12 23:02:04 +0100
committerWim <wim@42.be>2022-03-20 14:57:48 +0100
commitaefa70891cfd489fccb8a9567b5bdafb0f863ede (patch)
tree90fe7c91d7b33b2a1ed08ea3a94840860adc6fc1 /vendor/go.mau.fi/whatsmeow/connectionevents.go
parent1b9877fda45be021ea6a5677c78648cecc19dcd5 (diff)
downloadmatterbridge-msglm-aefa70891cfd489fccb8a9567b5bdafb0f863ede.tar.gz
matterbridge-msglm-aefa70891cfd489fccb8a9567b5bdafb0f863ede.tar.bz2
matterbridge-msglm-aefa70891cfd489fccb8a9567b5bdafb0f863ede.zip
Update vendor (whatsapp)
Diffstat (limited to 'vendor/go.mau.fi/whatsmeow/connectionevents.go')
-rw-r--r--vendor/go.mau.fi/whatsmeow/connectionevents.go29
1 files changed, 21 insertions, 8 deletions
diff --git a/vendor/go.mau.fi/whatsmeow/connectionevents.go b/vendor/go.mau.fi/whatsmeow/connectionevents.go
index c1a6e764..82a39184 100644
--- a/vendor/go.mau.fi/whatsmeow/connectionevents.go
+++ b/vendor/go.mau.fi/whatsmeow/connectionevents.go
@@ -33,7 +33,7 @@ func (cli *Client) handleStreamError(node *waBinary.Node) {
case code == "401" && conflictType == "device_removed":
cli.expectDisconnect()
cli.Log.Infof("Got device removed stream error, sending LoggedOut event and deleting session")
- go cli.dispatchEvent(&events.LoggedOut{OnConnect: false})
+ go cli.dispatchEvent(&events.LoggedOut{OnConnect: false, Reason: events.ConnectFailureLoggedOut})
err := cli.Store.Delete()
if err != nil {
cli.Log.Warnf("Failed to delete store after device_removed error: %v", err)
@@ -77,17 +77,30 @@ func (cli *Client) handleIB(node *waBinary.Node) {
func (cli *Client) handleConnectFailure(node *waBinary.Node) {
ag := node.AttrGetter()
- reason := ag.String("reason")
- if reason == "401" {
- cli.expectDisconnect()
- cli.Log.Infof("Got 401 connect failure, sending LoggedOut event and deleting session")
- go cli.dispatchEvent(&events.LoggedOut{OnConnect: true})
+ reason := events.ConnectFailureReason(ag.Int("reason"))
+ cli.expectDisconnect()
+ if reason.IsLoggedOut() {
+ cli.Log.Infof("Got %s connect failure, sending LoggedOut event and deleting session", reason)
+ go cli.dispatchEvent(&events.LoggedOut{OnConnect: true, Reason: reason})
err := cli.Store.Delete()
if err != nil {
- cli.Log.Warnf("Failed to delete store after 401 failure: %v", err)
+ cli.Log.Warnf("Failed to delete store after %d failure: %v", int(reason), err)
+ }
+ } else if reason == events.ConnectFailureTempBanned {
+ cli.Log.Warnf("Temporary ban connect failure: %s", node.XMLString())
+ expiryTimeUnix := ag.Int64("expire")
+ var expiryTime time.Time
+ if expiryTimeUnix > 0 {
+ expiryTime = time.Unix(expiryTimeUnix, 0)
}
+ go cli.dispatchEvent(&events.TemporaryBan{
+ Code: events.TempBanReason(ag.Int("code")),
+ Expire: expiryTime,
+ })
+ } else if reason == events.ConnectFailureClientOutdated {
+ cli.Log.Errorf("Client outdated (405) connect failure")
+ go cli.dispatchEvent(&events.ClientOutdated{})
} else {
- cli.expectDisconnect()
cli.Log.Warnf("Unknown connect failure: %s", node.XMLString())
go cli.dispatchEvent(&events.ConnectFailure{Reason: reason, Raw: node})
}