Send login QR codes to management room

This commit is contained in:
Tulir Asokan 2023-07-03 16:14:04 +03:00
parent 44e1cf7464
commit 6fca366d6a
2 changed files with 11 additions and 2 deletions

View file

@ -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)

11
user.go
View file

@ -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