Skip to content

Commit

Permalink
More comments
Browse files Browse the repository at this point in the history
  • Loading branch information
S7evinK committed Dec 19, 2024
1 parent 2f11ed9 commit 5cd4442
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions roomserver/acls/acls.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ type ServerACLs struct {
}

func NewServerACLs(db ServerACLDatabase) *ServerACLs {
// Add some logging, as this can take a while.
logrus.Infof("Loading server ACLs")
// Add some logging, as this can take a while on larger instances.
logrus.Infof("Loading server ACLs...")
start := time.Now()
aclCount := 0
defer func() {
Expand All @@ -62,13 +62,17 @@ func NewServerACLs(db ServerACLDatabase) *ServerACLs {
if err != nil {
logrus.WithError(err).Fatalf("Failed to get known rooms")
}
// For each room, let's see if we have a server ACL state event. If we
// do then we'll process it into memory so that we have the regexes to
// hand.

// No rooms with ACLs, don't bother hitting the DB again.
if len(rooms) == 0 {
return acls
}

// Get ACLs for the required rooms, bail if we are unable to get them.
events, err := db.GetBulkStateACLs(ctx, rooms)
if err != nil {
logrus.WithError(err).Errorf("Failed to get server ACLs for all rooms: %q", err)
// This is fatal, as we don't want to start without the ACLs.
logrus.WithError(err).Fatal("Failed to get server ACLs for all rooms")
}

aclCount = len(events)
Expand Down

0 comments on commit 5cd4442

Please sign in to comment.