mirror of
https://github.com/status-im/status-go.git
synced 2025-01-12 07:35:02 +00:00
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:
parent
67cf830097
commit
ff1df0c492
@ -89,7 +89,7 @@ var (
|
|||||||
ErrChatNotFoundError = errors.New("Chat not found")
|
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
|
// messageCacheIntervalMs is how long we should keep processed messages in the cache, in ms
|
||||||
var messageCacheIntervalMs uint64 = 1000 * 60 * 60 * 48
|
var messageCacheIntervalMs uint64 = 1000 * 60 * 60 * 48
|
||||||
|
@ -299,26 +299,12 @@ func (m *Messenger) handleCommunitiesSubscription(c chan *communities.Subscripti
|
|||||||
// We check every 5 minutes if we need to publish
|
// We check every 5 minutes if we need to publish
|
||||||
ticker := time.NewTicker(5 * time.Minute)
|
ticker := time.NewTicker(5 * time.Minute)
|
||||||
|
|
||||||
recentlyPublishedOrgs := func() map[string]*communities.Community {
|
recentlyPublishedOrgs := make(map[string]*communities.Community, 0)
|
||||||
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
|
|
||||||
}()
|
|
||||||
|
|
||||||
publishOrgAndDistributeEncryptionKeys := func(community *communities.Community) {
|
publishOrgAndDistributeEncryptionKeys := func(community *communities.Community) {
|
||||||
recentlyPublishedOrg := recentlyPublishedOrgs[community.IDString()]
|
recentlyPublishedOrg := recentlyPublishedOrgs[community.IDString()]
|
||||||
|
|
||||||
if recentlyPublishedOrg != nil && community.Clock() <= recentlyPublishedOrg.Clock() {
|
if recentlyPublishedOrg != nil && community.Clock() < recentlyPublishedOrg.Clock() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user