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.
This commit is contained in:
Patryk Osmaczko 2023-07-28 14:13:13 +02:00 committed by osmaczko
parent 4088edfa14
commit c1a98005e9
1 changed files with 12 additions and 1 deletions

View File

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