Disconnect if session restore fails

Otherwise the connection sticks around and can suddenly become logged in
This commit is contained in:
Tulir Asokan 2019-08-30 21:31:55 +03:00
parent 0d4453d2e8
commit fccf6e981f

View file

@ -210,6 +210,11 @@ func (user *User) RestoreSession() bool {
msg := format.RenderMarkdown("\u26a0 Failed to connect to WhatsApp. Make sure WhatsApp " +
"on your phone is reachable and use `reconnect` to try connecting again.")
_, _ = 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
}
user.ConnectionErrors = 0