forked from MirrorHub/mautrix-whatsapp
Add error code for normal transient disconnects
This commit is contained in:
parent
e1b734e52f
commit
0723d60205
2 changed files with 3 additions and 1 deletions
|
@ -33,6 +33,7 @@ const (
|
||||||
WAKeepaliveTimeout status.BridgeStateErrorCode = "wa-keepalive-timeout"
|
WAKeepaliveTimeout status.BridgeStateErrorCode = "wa-keepalive-timeout"
|
||||||
WAPhoneOffline status.BridgeStateErrorCode = "wa-phone-offline"
|
WAPhoneOffline status.BridgeStateErrorCode = "wa-phone-offline"
|
||||||
WAConnectionFailed status.BridgeStateErrorCode = "wa-connection-failed"
|
WAConnectionFailed status.BridgeStateErrorCode = "wa-connection-failed"
|
||||||
|
WADisconnected status.BridgeStateErrorCode = "wa-transient-disconnect"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -45,6 +46,7 @@ func init() {
|
||||||
WAKeepaliveTimeout: "The WhatsApp web servers are not responding. The bridge will try to reconnect.",
|
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.",
|
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.",
|
WAConnectionFailed: "Connecting to the WhatsApp web servers failed.",
|
||||||
|
WADisconnected: "Disconnected from WhatsApp. Trying to reconnect.",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
user.go
2
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.
|
// 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
|
// 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) {
|
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)
|
user.bridge.Metrics.TrackConnectionState(user.JID, false)
|
||||||
case *events.Contact:
|
case *events.Contact:
|
||||||
|
|
Loading…
Reference in a new issue