From 0723d60205416c3b9acf2f3b2a29b237e99f3607 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Fri, 13 Jan 2023 01:20:04 +0200 Subject: [PATCH] Add error code for normal transient disconnects --- bridgestate.go | 2 ++ user.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/bridgestate.go b/bridgestate.go index 7d11d7f..afd67bf 100644 --- a/bridgestate.go +++ b/bridgestate.go @@ -33,6 +33,7 @@ const ( WAKeepaliveTimeout status.BridgeStateErrorCode = "wa-keepalive-timeout" WAPhoneOffline status.BridgeStateErrorCode = "wa-phone-offline" WAConnectionFailed status.BridgeStateErrorCode = "wa-connection-failed" + WADisconnected status.BridgeStateErrorCode = "wa-transient-disconnect" ) func init() { @@ -45,6 +46,7 @@ func init() { WAKeepaliveTimeout: "The WhatsApp web servers are not responding. The bridge will try to reconnect.", WAPhoneOffline: "Your phone hasn't been seen in over 12 days. The bridge is currently connected, but will get disconnected if you don't open the app soon.", WAConnectionFailed: "Connecting to the WhatsApp web servers failed.", + WADisconnected: "Disconnected from WhatsApp. Trying to reconnect.", }) } diff --git a/user.go b/user.go index d2d558d..dfbe159 100644 --- a/user.go +++ b/user.go @@ -841,7 +841,7 @@ func (user *User) HandleEvent(event interface{}) { // Don't send the normal transient disconnect state if we're already in a different transient disconnect state. // TODO remove this if/when the phone offline state is moved to a sub-state of CONNECTED if user.BridgeState.GetPrev().Error != WAPhoneOffline && user.PhoneRecentlySeen(false) { - go user.BridgeState.Send(status.BridgeState{StateEvent: status.StateTransientDisconnect, Message: "Disconnected from WhatsApp. Trying to reconnect."}) + go user.BridgeState.Send(status.BridgeState{StateEvent: status.StateTransientDisconnect, Error: WADisconnected}) } user.bridge.Metrics.TrackConnectionState(user.JID, false) case *events.Contact: