Browse Source

Fix handling login events

Tulir Asokan 3 years ago
parent
commit
b8a8dcffaf
2 changed files with 8 additions and 8 deletions
  1. 4 4
      commands.go
  2. 4 4
      provisioning.go

+ 4 - 4
commands.go

@@ -510,14 +510,14 @@ func (handler *CommandHandler) CommandLogin(ce *CommandEvent) {
 	var qrEventID id.EventID
 	for item := range qrChan {
 		switch item.Event {
-		case whatsmeow.QRChannelSuccess.Code:
+		case whatsmeow.QRChannelSuccess.Event:
 			jid := ce.User.Client.Store.ID
 			ce.Reply("Successfully logged in as +%s (device #%d)", jid.User, jid.Device)
-		case whatsmeow.QRChannelTimeout.Code:
+		case whatsmeow.QRChannelTimeout.Event:
 			ce.Reply("QR code timed out. Please restart the login.")
-		case whatsmeow.QRChannelErrUnexpectedEvent.Code:
+		case whatsmeow.QRChannelErrUnexpectedEvent.Event:
 			ce.Reply("Failed to log in: unexpected connection event from server")
-		case whatsmeow.QRChannelScannedWithoutMultidevice.Code:
+		case whatsmeow.QRChannelScannedWithoutMultidevice.Event:
 			ce.Reply("Please enable the WhatsApp multidevice beta and scan the QR code again.")
 		case "error":
 			ce.Reply("Failed to log in: %v", item.Error)

+ 4 - 4
provisioning.go

@@ -308,7 +308,7 @@ func (prov *ProvisioningAPI) Login(w http.ResponseWriter, r *http.Request) {
 		select {
 		case evt := <-qrChan:
 			switch evt.Event {
-			case whatsmeow.QRChannelSuccess.Code:
+			case whatsmeow.QRChannelSuccess.Event:
 				jid := user.Client.Store.ID
 				user.log.Debugln("Successful login as", jid, "via provisioning API")
 				_ = c.WriteJSON(map[string]interface{}{
@@ -316,19 +316,19 @@ func (prov *ProvisioningAPI) Login(w http.ResponseWriter, r *http.Request) {
 					"jid":     jid,
 					"phone":   fmt.Sprintf("+%s", jid.User),
 				})
-			case whatsmeow.QRChannelTimeout.Code:
+			case whatsmeow.QRChannelTimeout.Event:
 				user.log.Debugln("Login via provisioning API timed out")
 				_ = c.WriteJSON(Error{
 					Error:   "QR code scan timed out. Please try again.",
 					ErrCode: "login timed out",
 				})
-			case whatsmeow.QRChannelErrUnexpectedEvent.Code:
+			case whatsmeow.QRChannelErrUnexpectedEvent.Event:
 				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.Code:
+			case whatsmeow.QRChannelScannedWithoutMultidevice.Event:
 				_ = c.WriteJSON(Error{
 					Error:   "Please enable the WhatsApp multidevice beta and scan the QR code again.",
 					ErrCode: "multidevice not enabled",