Add proper error message for outdated client errors

This commit is contained in:
Tulir Asokan 2022-02-17 15:33:31 +02:00
parent 66d0817081
commit 3c274e6d35
5 changed files with 15 additions and 3 deletions

View file

@ -522,6 +522,8 @@ func (handler *CommandHandler) CommandLogin(ce *CommandEvent) {
ce.Reply("QR code timed out. Please restart the login.")
case whatsmeow.QRChannelErrUnexpectedEvent.Event:
ce.Reply("Failed to log in: unexpected connection event from server")
case whatsmeow.QRChannelClientOutdated.Event:
ce.Reply("Failed to log in: outdated client. The bridge must be updated to continue.")
case whatsmeow.QRChannelScannedWithoutMultidevice.Event:
ce.Reply("Please enable the WhatsApp multidevice beta and scan the QR code again.")
case "error":

2
go.mod
View file

@ -10,7 +10,7 @@ require (
github.com/prometheus/client_golang v1.11.1
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
github.com/tidwall/gjson v1.14.0
go.mau.fi/whatsmeow v0.0.0-20220217121823-b7d4c5a8e8cc
go.mau.fi/whatsmeow v0.0.0-20220217133111-7d4c399d0640
golang.org/x/image v0.0.0-20211028202545-6944b10bf410
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd
google.golang.org/protobuf v1.27.1

4
go.sum
View file

@ -120,8 +120,8 @@ github.com/tidwall/sjson v1.2.4 h1:cuiLzLnaMeBhRmEv00Lpk3tkYrcxpmbU81tAY4Dw0tc=
github.com/tidwall/sjson v1.2.4/go.mod h1:098SZ494YoMWPmMO6ct4dcFnqxwj9r/gF0Etp19pSNM=
go.mau.fi/libsignal v0.0.0-20211109153248-a67163214910 h1:9FFhG0OmkuMau5UEaTgiUQ+7cSbtbOQ7hiWKdN8OI3I=
go.mau.fi/libsignal v0.0.0-20211109153248-a67163214910/go.mod h1:AufGrvVh+00Nc07Jm4hTquh7yleZyn20tKJI2wCPAKg=
go.mau.fi/whatsmeow v0.0.0-20220217121823-b7d4c5a8e8cc h1:nmKmURePfVfpK+qLeAZvJIMbgpAKtfYcqeXwXAaFUls=
go.mau.fi/whatsmeow v0.0.0-20220217121823-b7d4c5a8e8cc/go.mod h1:NNI4Ah/B27mfQNChJMD1iSO8+HS+fQ4WqNuQ8Mh2/XI=
go.mau.fi/whatsmeow v0.0.0-20220217133111-7d4c399d0640 h1:8WEXxj18qt6B8KhCW510qtNZjQUiqV2u3nvhNy8HV30=
go.mau.fi/whatsmeow v0.0.0-20220217133111-7d4c399d0640/go.mod h1:NNI4Ah/B27mfQNChJMD1iSO8+HS+fQ4WqNuQ8Mh2/XI=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=

View file

@ -455,6 +455,12 @@ func (prov *ProvisioningAPI) Login(w http.ResponseWriter, r *http.Request) {
Error: "Got unexpected event while waiting for QRs, perhaps you're already logged in?",
ErrCode: "unexpected event",
})
case whatsmeow.QRChannelClientOutdated.Event:
user.log.Debugln("Login via provisioning API failed due to outdated client")
_ = c.WriteJSON(Error{
Error: "Got client outdated error while waiting for QRs. The bridge must be updated to continue.",
ErrCode: "bridge outdated",
})
case whatsmeow.QRChannelScannedWithoutMultidevice.Event:
_ = c.WriteJSON(Error{
Error: "Please enable the WhatsApp multidevice beta and scan the QR code again.",

View file

@ -591,6 +591,10 @@ func (user *User) HandleEvent(event interface{}) {
case *events.ConnectFailure:
go user.sendBridgeState(BridgeState{StateEvent: StateUnknownError, Message: fmt.Sprintf("Unknown connection failure: %s", v.Reason)})
user.bridge.Metrics.TrackConnectionState(user.JID, false)
case *events.ClientOutdated:
user.log.Errorfln("Got a client outdated connect failure. The bridge is likely out of date, please update immediately.")
go user.sendBridgeState(BridgeState{StateEvent: StateUnknownError, Message: "Connect failure: 405 client outdated"})
user.bridge.Metrics.TrackConnectionState(user.JID, false)
case *events.TemporaryBan:
go user.sendBridgeState(BridgeState{StateEvent: StateBadCredentials, Message: v.String()})
user.bridge.Metrics.TrackConnectionState(user.JID, false)