diff --git a/go.mod b/go.mod index 5a775bb..af179b4 100644 --- a/go.mod +++ b/go.mod @@ -16,4 +16,4 @@ require ( maunium.net/go/mautrix v0.9.0 ) -replace github.com/Rhymen/go-whatsapp => github.com/tulir/go-whatsapp v0.4.0-rc.3 +replace github.com/Rhymen/go-whatsapp => github.com/tulir/go-whatsapp v0.4.0-rc.3.0.20210305145305-1afcd8642930 diff --git a/go.sum b/go.sum index f8476d2..16a7d99 100644 --- a/go.sum +++ b/go.sum @@ -311,6 +311,8 @@ github.com/tulir/go-whatsapp v0.4.0-rc.2.0.20210225152147-6bc95e2c807b h1:1RezMf github.com/tulir/go-whatsapp v0.4.0-rc.2.0.20210225152147-6bc95e2c807b/go.mod h1:rwwuTh1bKqhgrRvOBAr8hDqtuz8Cc1Quqw/0BeXb+/E= github.com/tulir/go-whatsapp v0.4.0-rc.3 h1:Z744njj2Jmwdh8r4wWJg5gRlFoh9P0aeOabc2Kc3bE0= github.com/tulir/go-whatsapp v0.4.0-rc.3/go.mod h1:rwwuTh1bKqhgrRvOBAr8hDqtuz8Cc1Quqw/0BeXb+/E= +github.com/tulir/go-whatsapp v0.4.0-rc.3.0.20210305145305-1afcd8642930 h1:9FMxSLplYTMB4HQWT0XmlINAHs3AgwamFxO4S2G0M9s= +github.com/tulir/go-whatsapp v0.4.0-rc.3.0.20210305145305-1afcd8642930/go.mod h1:rwwuTh1bKqhgrRvOBAr8hDqtuz8Cc1Quqw/0BeXb+/E= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= diff --git a/portal.go b/portal.go index 4ff88d4..28e5161 100644 --- a/portal.go +++ b/portal.go @@ -1950,15 +1950,19 @@ func (portal *Portal) sendMatrixConnectionError(sender *User, eventID id.EventID portal.log.Debugln("Ignoring event", eventID, "from", sender.MXID, "as user has no session") return true } else if !sender.IsConnected() { - portal.log.Debugln("Ignoring event", eventID, "from", sender.MXID, "as user is not connected") inRoom := "" if portal.IsPrivateChat() { inRoom = " in your management room" } - reconnect := fmt.Sprintf("Use `%s reconnect`%s to reconnect.", portal.bridge.Config.Bridge.CommandPrefix, inRoom) if sender.IsLoginInProgress() { - reconnect = "You have a login attempt in progress, please wait." + portal.log.Debugln("Waiting for connection before handling event", eventID, "from", sender.MXID) + sender.Conn.WaitForLogin() + if sender.IsConnected() { + return false + } } + reconnect := fmt.Sprintf("Use `%s reconnect`%s to reconnect.", portal.bridge.Config.Bridge.CommandPrefix, inRoom) + portal.log.Debugln("Ignoring event", eventID, "from", sender.MXID, "as user is not connected") msg := format.RenderMarkdown("\u26a0 You are not connected to WhatsApp, so your message was not bridged. "+reconnect, true, false) msg.MsgType = event.MsgNotice _, err := portal.sendMainIntentMessage(msg)