diff options
author | Wim <wim@42.be> | 2023-08-05 20:43:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-05 20:43:19 +0200 |
commit | 56e7bd01ca09ad52b0c4f48f146a20a4f1b78696 (patch) | |
tree | b1355645342667209263cbd355dc0b4254f1e8fe /vendor/go.mau.fi/whatsmeow/connectionevents.go | |
parent | 9459495484d6e06a3d46de64fccd8d06f7ccc72c (diff) | |
download | matterbridge-msglm-56e7bd01ca09ad52b0c4f48f146a20a4f1b78696.tar.gz matterbridge-msglm-56e7bd01ca09ad52b0c4f48f146a20a4f1b78696.tar.bz2 matterbridge-msglm-56e7bd01ca09ad52b0c4f48f146a20a4f1b78696.zip |
Diffstat (limited to 'vendor/go.mau.fi/whatsmeow/connectionevents.go')
-rw-r--r-- | vendor/go.mau.fi/whatsmeow/connectionevents.go | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/vendor/go.mau.fi/whatsmeow/connectionevents.go b/vendor/go.mau.fi/whatsmeow/connectionevents.go index 3a6d9e29..c20fe42a 100644 --- a/vendor/go.mau.fi/whatsmeow/connectionevents.go +++ b/vendor/go.mau.fi/whatsmeow/connectionevents.go @@ -11,6 +11,7 @@ import ( "time" waBinary "go.mau.fi/whatsmeow/binary" + "go.mau.fi/whatsmeow/store" "go.mau.fi/whatsmeow/types" "go.mau.fi/whatsmeow/types/events" ) @@ -79,9 +80,17 @@ func (cli *Client) handleIB(node *waBinary.Node) { func (cli *Client) handleConnectFailure(node *waBinary.Node) { ag := node.AttrGetter() reason := events.ConnectFailureReason(ag.Int("reason")) - // Let the auto-reconnect happen for 503s, for all other failures block it - if reason != events.ConnectFailureServiceUnavailable { + message := ag.OptionalString("message") + willAutoReconnect := true + switch { + default: + // By default, expect a disconnect (i.e. prevent auto-reconnect) cli.expectDisconnect() + willAutoReconnect = false + case reason == events.ConnectFailureServiceUnavailable: + // Auto-reconnect for 503s + case reason == 500 && message == "biz vname fetch error": + // These happen for business accounts randomly, also auto-reconnect } if reason.IsLoggedOut() { cli.Log.Infof("Got %s connect failure, sending LoggedOut event and deleting session", reason) @@ -97,13 +106,13 @@ func (cli *Client) handleConnectFailure(node *waBinary.Node) { Expire: time.Duration(ag.Int("expire")) * time.Second, }) } else if reason == events.ConnectFailureClientOutdated { - cli.Log.Errorf("Client outdated (405) connect failure") + cli.Log.Errorf("Client outdated (405) connect failure (client version: %s)", store.GetWAVersion().String()) go cli.dispatchEvent(&events.ClientOutdated{}) - } else if reason == events.ConnectFailureServiceUnavailable { - cli.Log.Warnf("Got 503 connect failure, assuming automatic reconnect will handle it") + } else if willAutoReconnect { + cli.Log.Warnf("Got %d/%s connect failure, assuming automatic reconnect will handle it", int(reason), message) } else { cli.Log.Warnf("Unknown connect failure: %s", node.XMLString()) - go cli.dispatchEvent(&events.ConnectFailure{Reason: reason, Raw: node}) + go cli.dispatchEvent(&events.ConnectFailure{Reason: reason, Message: message, Raw: node}) } } |