forked from MirrorHub/mautrix-whatsapp
Disconnect if session restore fails
Otherwise the connection sticks around and can suddenly become logged in
This commit is contained in:
parent
0d4453d2e8
commit
fccf6e981f
1 changed files with 5 additions and 0 deletions
5
user.go
5
user.go
|
@ -210,6 +210,11 @@ func (user *User) RestoreSession() bool {
|
||||||
msg := format.RenderMarkdown("\u26a0 Failed to connect to WhatsApp. Make sure WhatsApp " +
|
msg := format.RenderMarkdown("\u26a0 Failed to connect to WhatsApp. Make sure WhatsApp " +
|
||||||
"on your phone is reachable and use `reconnect` to try connecting again.")
|
"on your phone is reachable and use `reconnect` to try connecting again.")
|
||||||
_, _ = user.bridge.Bot.SendMessageEvent(user.ManagementRoom, mautrix.EventMessage, msg)
|
_, _ = user.bridge.Bot.SendMessageEvent(user.ManagementRoom, mautrix.EventMessage, msg)
|
||||||
|
user.log.Debugln("Disconnecting due to failed session restore...")
|
||||||
|
_, err := user.Conn.Disconnect()
|
||||||
|
if err != nil {
|
||||||
|
user.log.Errorln("Failed to disconnect after failed session restore:", err)
|
||||||
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
user.ConnectionErrors = 0
|
user.ConnectionErrors = 0
|
||||||
|
|
Loading…
Reference in a new issue