@@ -49,20 +49,9 @@ func (am *DefaultAccountManager) GetPeers(ctx context.Context, accountID, userID
49
49
return nil , err
50
50
}
51
51
52
- peers := make ([]* nbpeer.Peer , 0 )
53
- peersMap := make (map [string ]* nbpeer.Peer )
54
-
55
- for _ , peer := range accountPeers {
56
- if user .IsRegularUser () && user .Id != peer .UserID {
57
- // only display peers that belong to the current user if the current user is not an admin
58
- continue
59
- }
60
- peers = append (peers , peer )
61
- peersMap [peer .ID ] = peer
62
- }
63
-
52
+ // @note if the user has permission to read peers it shows all account peers
64
53
if allowed {
65
- return peers , nil
54
+ return accountPeers , nil
66
55
}
67
56
68
57
settings , err := am .Store .GetAccountSettings (ctx , store .LockingStrengthShare , accountID )
@@ -74,6 +63,18 @@ func (am *DefaultAccountManager) GetPeers(ctx context.Context, accountID, userID
74
63
return []* nbpeer.Peer {}, nil
75
64
}
76
65
66
+ // @note if it does not have permission read peers then only display it's own peers
67
+ peers := make ([]* nbpeer.Peer , 0 )
68
+ peersMap := make (map [string ]* nbpeer.Peer )
69
+
70
+ for _ , peer := range accountPeers {
71
+ if user .Id != peer .UserID {
72
+ continue
73
+ }
74
+ peers = append (peers , peer )
75
+ peersMap [peer .ID ] = peer
76
+ }
77
+
77
78
return am .getUserAccessiblePeers (ctx , accountID , peersMap , peers )
78
79
}
79
80
0 commit comments