Skip to content

Commit

Permalink
fix: decouple permissions reevaluation from torrent client readiness
Browse files Browse the repository at this point in the history
  • Loading branch information
osmaczko committed Oct 22, 2023
1 parent bd245ab commit dc6fe56
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions protocol/messenger.go
Original file line number Diff line number Diff line change
Expand Up @@ -835,20 +835,22 @@ func (m *Messenger) Start() (*MessengerResponse, error) {
return nil, err
}

controlledCommunities, err := m.communitiesManager.Controlled()
if err != nil {
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)
}()

for _, c := range controlledCommunities {
if c.Joined() && c.HasTokenPermissions() {
go m.communitiesManager.ReevaluateMembersPeriodically(c.ID())
}
}
available := m.SubscribeMailserverAvailable()
go func() {
<-available
m.InitHistoryArchiveTasks(controlledCommunities)
}()
}

for _, c := range controlledCommunities {
if c.Joined() && c.HasTokenPermissions() {
go m.communitiesManager.ReevaluateMembersPeriodically(c.ID())
}
}

Expand Down

0 comments on commit dc6fe56

Please sign in to comment.