From 4695ce450f3f0cd34c03122d3343d98357ec2c9e Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Thu, 28 Oct 2021 21:22:34 +0300 Subject: [PATCH] Show error message if user scans QR code with multidevice disabled --- commands.go | 2 ++ go.mod | 2 +- go.sum | 4 ++-- provisioning.go | 11 +++++++++++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/commands.go b/commands.go index 60b270c..5388336 100644 --- a/commands.go +++ b/commands.go @@ -420,6 +420,8 @@ func (handler *CommandHandler) CommandLogin(ce *CommandEvent) { ce.Reply("QR code timed out. Please restart the login.") case whatsmeow.QRChannelErrUnexpectedEvent: ce.Reply("Failed to log in: unexpected connection event from server") + case whatsmeow.QRChannelScannedWithoutMultidevice: + ce.Reply("Please enable the WhatsApp multidevice beta and scan the QR code again.") default: qrEventID = ce.User.sendQR(ce, string(item), qrEventID) } diff --git a/go.mod b/go.mod index 286d7e9..ef8678b 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/mattn/go-sqlite3 v1.14.9 github.com/prometheus/client_golang v1.11.0 github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e - go.mau.fi/whatsmeow v0.0.0-20211028095847-2a72655ef600 + go.mau.fi/whatsmeow v0.0.0-20211028182103-c52e72e7c66f golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d google.golang.org/protobuf v1.27.1 gopkg.in/yaml.v2 v2.4.0 diff --git a/go.sum b/go.sum index e26cce5..28d7224 100644 --- a/go.sum +++ b/go.sum @@ -139,8 +139,8 @@ github.com/tidwall/sjson v1.2.3 h1:5+deguEhHSEjmuICXZ21uSSsXotWMA0orU783+Z7Cp8= github.com/tidwall/sjson v1.2.3/go.mod h1:5WdjKx3AQMvCJ4RG6/2UYT7dLrGvJUV1x4jdTAyGvZs= go.mau.fi/libsignal v0.0.0-20211024113310-f9fc6a1855f2 h1:xpQTMgJGGaF+c8jV/LA/FVXAPJxZbSAGeflOc+Ly6uQ= go.mau.fi/libsignal v0.0.0-20211024113310-f9fc6a1855f2/go.mod h1:3XlVlwOfp8f9Wri+C1D4ORqgUsN4ZvunJOoPjQMBhos= -go.mau.fi/whatsmeow v0.0.0-20211028095847-2a72655ef600 h1:3huw0OOUNmU1c9vJHifEdTJJnFn6UchoHFaazdHkd34= -go.mau.fi/whatsmeow v0.0.0-20211028095847-2a72655ef600/go.mod h1:ODEmmqeUn9eBDQHFc1S902YA3YFLtmaBujYRRFl53jI= +go.mau.fi/whatsmeow v0.0.0-20211028182103-c52e72e7c66f h1:/2pIpCW3g2D99UbPJWFwUwKFb1bxTycaueDsYqWWxNE= +go.mau.fi/whatsmeow v0.0.0-20211028182103-c52e72e7c66f/go.mod h1:ODEmmqeUn9eBDQHFc1S902YA3YFLtmaBujYRRFl53jI= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 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= diff --git a/provisioning.go b/provisioning.go index eadb10b..d3e4bf1 100644 --- a/provisioning.go +++ b/provisioning.go @@ -315,6 +315,17 @@ func (prov *ProvisioningAPI) Login(w http.ResponseWriter, r *http.Request) { Error: "QR code scan timed out. Please try again.", ErrCode: "login timed out", }) + case whatsmeow.QRChannelErrUnexpectedEvent: + user.log.Debugln("Login via provisioning API failed due to unexpected event") + _ = c.WriteJSON(Error{ + Error: "Got unexpected event while waiting for QRs, perhaps you're already logged in?", + ErrCode: "unexpected event", + }) + case whatsmeow.QRChannelScannedWithoutMultidevice: + _ = c.WriteJSON(Error{ + Error: "Please enable the WhatsApp multidevice beta and scan the QR code again.", + ErrCode: "multidevice not enabled", + }) default: _ = c.WriteJSON(map[string]interface{}{ "code": string(evt),