From fccf6e981f42e47cf094d5b0cb6c124d3c8ac611 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Fri, 30 Aug 2019 21:31:55 +0300 Subject: [PATCH] Disconnect if session restore fails Otherwise the connection sticks around and can suddenly become logged in --- user.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/user.go b/user.go index ea1ace2..1d72c2d 100644 --- a/user.go +++ b/user.go @@ -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