fix_: publish community periodically (#5709)

* fix_: publish community at app start

* fix_: allow publishing community with same clock

* chore_: increase community publish interval to 24 hours
This commit is contained in:
Igor Sirotin 2024-08-14 10:32:11 +01:00 committed by GitHub
parent 67cf830097
commit ff1df0c492
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 17 deletions

View File

@ -89,7 +89,7 @@ var (
ErrChatNotFoundError = errors.New("Chat not found")
)
var communityAdvertiseIntervalSecond int64 = 60 * 60
const communityAdvertiseIntervalSecond int64 = 24 * 60 * 60
// messageCacheIntervalMs is how long we should keep processed messages in the cache, in ms
var messageCacheIntervalMs uint64 = 1000 * 60 * 60 * 48

View File

@ -299,26 +299,12 @@ func (m *Messenger) handleCommunitiesSubscription(c chan *communities.Subscripti
// We check every 5 minutes if we need to publish
ticker := time.NewTicker(5 * time.Minute)
recentlyPublishedOrgs := func() map[string]*communities.Community {
result := make(map[string]*communities.Community)
controlledCommunities, err := m.communitiesManager.Controlled()
if err != nil {
m.logger.Warn("failed to retrieve orgs", zap.Error(err))
return result
}
for _, org := range controlledCommunities {
result[org.IDString()] = org
}
return result
}()
recentlyPublishedOrgs := make(map[string]*communities.Community, 0)
publishOrgAndDistributeEncryptionKeys := func(community *communities.Community) {
recentlyPublishedOrg := recentlyPublishedOrgs[community.IDString()]
if recentlyPublishedOrg != nil && community.Clock() <= recentlyPublishedOrg.Clock() {
if recentlyPublishedOrg != nil && community.Clock() < recentlyPublishedOrg.Clock() {
return
}