fix: decouple permissions reevaluation from torrent client readiness

This commit is contained in:
Patryk Osmaczko 2023-10-20 00:15:45 +02:00 committed by osmaczko
parent bd245ab45b
commit dc6fe5613a
1 changed files with 15 additions and 13 deletions

View File

@ -835,20 +835,22 @@ func (m *Messenger) Start() (*MessengerResponse, error) {
return nil, err
}
if m.torrentClientReady() {
controlledCommunities, err := m.communitiesManager.Controlled()
if err == nil && len(controlledCommunities) > 0 {
available := m.SubscribeMailserverAvailable()
go func() {
<-available
m.InitHistoryArchiveTasks(controlledCommunities)
}()
controlledCommunities, err := m.communitiesManager.Controlled()
if err != nil {
return nil, err
}
for _, c := range controlledCommunities {
if c.Joined() && c.HasTokenPermissions() {
go m.communitiesManager.ReevaluateMembersPeriodically(c.ID())
}
}
if m.torrentClientReady() {
available := m.SubscribeMailserverAvailable()
go func() {
<-available
m.InitHistoryArchiveTasks(controlledCommunities)
}()
}
for _, c := range controlledCommunities {
if c.Joined() && c.HasTokenPermissions() {
go m.communitiesManager.ReevaluateMembersPeriodically(c.ID())
}
}