From 6fca366d6a39f3670dc80e19922c9dbdd2869e40 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Mon, 3 Jul 2023 16:14:04 +0300 Subject: [PATCH] Send login QR codes to management room --- commands.go | 2 ++ user.go | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/commands.go b/commands.go index 7645f17..fac97ce 100644 --- a/commands.go +++ b/commands.go @@ -83,6 +83,8 @@ func fnLogin(ce *WrappedCommandEvent) { return } + ce.User.hackyLoginCommand = ce + ce.User.hackyLoginCommandPrevEvent = "" _, err := ce.User.Login(context.Background()) if err != nil { ce.User.log.Errorf("Failed to log in:", err) diff --git a/user.go b/user.go index 9daf8dc..0a2fea2 100644 --- a/user.go +++ b/user.go @@ -69,6 +69,9 @@ type User struct { spaceMembershipChecked bool DoublePuppetIntent *appservice.IntentAPI + + hackyLoginCommand *WrappedCommandEvent + hackyLoginCommandPrevEvent id.EventID } func (br *GMBridge) getUserByMXID(userID id.UserID, onlyIfExists bool) *User { @@ -524,9 +527,13 @@ func (user *User) sendMarkdownBridgeAlert(formatString string, args ...interface func (user *User) HandleEvent(event interface{}) { switch v := event.(type) { case *events.QR: - // These should be here - user.zlog.Info().Msg(v.URL) + // This shouldn't be here + if user.hackyLoginCommand != nil { + user.hackyLoginCommandPrevEvent = user.sendQR(user.hackyLoginCommand, v.URL, user.hackyLoginCommandPrevEvent) + } case *events.PairSuccessful: + user.hackyLoginCommand = nil + user.hackyLoginCommandPrevEvent = "" user.tryAutomaticDoublePuppeting() user.Phone = v.PairDeviceData.Mobile.RegistrationID user.Session.PhoneInfo = v.PairDeviceData.Mobile