Skip to content

Commit

Permalink
Skip network map check if not regular user (#2402)
Browse files Browse the repository at this point in the history
when getting all peers we don't need to calculate network map when not a regular user
  • Loading branch information
mlsmaycon authored Aug 7, 2024
1 parent 855fba8 commit 54d8968
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions management/server/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,14 @@ func (am *DefaultAccountManager) GetPeers(ctx context.Context, accountID, userID
peers := make([]*nbpeer.Peer, 0)
peersMap := make(map[string]*nbpeer.Peer)

if !user.HasAdminPower() && !user.IsServiceUser && account.Settings.RegularUsersViewBlocked {
regularUser := !user.HasAdminPower() && !user.IsServiceUser

if regularUser && account.Settings.RegularUsersViewBlocked {
return peers, nil
}

for _, peer := range account.Peers {
if !(user.HasAdminPower() || user.IsServiceUser) && user.Id != peer.UserID {
if regularUser && user.Id != peer.UserID {
// only display peers that belong to the current user if the current user is not an admin
continue
}
Expand All @@ -79,6 +81,10 @@ func (am *DefaultAccountManager) GetPeers(ctx context.Context, accountID, userID
peersMap[peer.ID] = p
}

if !regularUser {
return peers, nil
}

// fetch all the peers that have access to the user's peers
for _, peer := range peers {
aclPeers, _ := account.getPeerConnectionResources(ctx, peer.ID, approvedPeersMap)
Expand Down

0 comments on commit 54d8968

Please sign in to comment.