forked from MirrorHub/mautrix-whatsapp
Wait for connection before handling message when login is in progress
This commit is contained in:
parent
001746be07
commit
8a6877746d
3 changed files with 10 additions and 4 deletions
2
go.mod
2
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
|
||||
|
|
2
go.sum
2
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=
|
||||
|
|
10
portal.go
10
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)
|
||||
|
|
Loading…
Reference in a new issue