From c1a98005e926981a15eb98a37bd34e99140f5e97 Mon Sep 17 00:00:00 2001 From: Patryk Osmaczko Date: Fri, 28 Jul 2023 14:13:13 +0200 Subject: [PATCH] chore: signal client with published community Some of the changes done to the community are done async, client must be notified about them to relfect current state. --- protocol/messenger_communities.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/protocol/messenger_communities.go b/protocol/messenger_communities.go index 199d753c1..b5f4b2328 100644 --- a/protocol/messenger_communities.go +++ b/protocol/messenger_communities.go @@ -238,8 +238,19 @@ func (m *Messenger) handleCommunitiesSubscription(c chan *communities.Subscripti } m.logger.Debug("published org") + recentlyPublishedOrg := recentlyPublishedOrgs[community.IDString()] + + // signal client with published community + if m.config.messengerSignalsHandler != nil { + if recentlyPublishedOrg == nil || community.Clock() > recentlyPublishedOrg.Clock() { + response := &MessengerResponse{} + response.AddCommunity(community) + m.config.messengerSignalsHandler.MessengerResponse(response) + } + } + // evaluate and distribute encryption keys (if any) - encryptionKeyActions := communities.EvaluateCommunityEncryptionKeyActions(recentlyPublishedOrgs[community.IDString()], community) + encryptionKeyActions := communities.EvaluateCommunityEncryptionKeyActions(recentlyPublishedOrg, community) err = m.communitiesKeyDistributor.Distribute(community, encryptionKeyActions) if err != nil { m.logger.Warn("failed to distribute encryption keys", zap.Error(err))