From c88e5ec5503e6fae764f8324fc44007b018d9374 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Thu, 10 Aug 2023 14:09:08 +0300 Subject: [PATCH] Fetch conversation info if necessary when creating portal --- portal.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/portal.go b/portal.go index f312943..5457bb1 100644 --- a/portal.go +++ b/portal.go @@ -510,10 +510,6 @@ func (portal *Portal) handleExistingMessage(ctx context.Context, source *User, e } func (portal *Portal) handleMessage(source *User, evt *gmproto.Message) { - if len(portal.MXID) == 0 { - portal.zlog.Warn().Msg("handleMessage called even though portal.MXID is empty") - return - } eventTS := time.UnixMicro(evt.GetTimestamp()) if eventTS.After(portal.lastMessageTS) { portal.lastMessageTS = eventTS @@ -1216,6 +1212,15 @@ func (portal *Portal) CreateMatrixRoom(user *User, conv *gmproto.Conversation) e return nil } + var err error + if conv == nil { + portal.zlog.Debug().Msg("CreateMatrixRoom called without conversation info, requesting from phone") + conv, err = user.Client.GetConversation(portal.ID) + if err != nil { + return fmt.Errorf("failed to get conversation info: %w", err) + } + } + members := portal.UpdateMetadata(user, conv) if portal.IsPrivateChat() && portal.GetDMPuppet() == nil { @@ -1224,7 +1229,7 @@ func (portal *Portal) CreateMatrixRoom(user *User, conv *gmproto.Conversation) e } intent := portal.MainIntent() - if err := intent.EnsureRegistered(); err != nil { + if err = intent.EnsureRegistered(); err != nil { return err }