From 44e1cf7464ea564e3b283c1bc7dfadeb7023f8d0 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Mon, 3 Jul 2023 00:13:36 +0300 Subject: [PATCH] Don't log re-finding other user ID all the time --- portal.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/portal.go b/portal.go index 232ca72..105d3ad 100644 --- a/portal.go +++ b/portal.go @@ -417,7 +417,7 @@ func (portal *Portal) markHandled(info *binary.Message, mxids map[string]id.Even return msg } -func (portal *Portal) SyncParticipants(source *User, metadata *binary.Conversation) (userIDs []id.UserID) { +func (portal *Portal) SyncParticipants(source *User, metadata *binary.Conversation) (userIDs []id.UserID, changed bool) { var firstParticipant *binary.Participant var manyParticipants bool for _, participant := range metadata.Participants { @@ -445,14 +445,15 @@ func (portal *Portal) SyncParticipants(source *User, metadata *binary.Conversati } } } - if !metadata.IsGroupChat && !manyParticipants { + if !metadata.IsGroupChat && !manyParticipants && portal.OtherUserID != firstParticipant.Id.ParticipantID { portal.zlog.Info(). Str("old_other_user_id", portal.OtherUserID). Str("new_other_user_id", firstParticipant.Id.ParticipantID). Msg("Found other user ID in DM") portal.OtherUserID = firstParticipant.Id.ParticipantID + changed = true } - return userIDs + return userIDs, changed } func (portal *Portal) UpdateName(name string, updateInfo bool) bool { @@ -492,8 +493,7 @@ func (portal *Portal) UpdateName(name string, updateInfo bool) bool { } func (portal *Portal) UpdateMetadata(user *User, info *binary.Conversation) []id.UserID { - participants := portal.SyncParticipants(user, info) - update := false + participants, update := portal.SyncParticipants(user, info) if portal.SelfUserID != info.SelfParticipantID { portal.SelfUserID = info.SelfParticipantID update = true