Remove premature optimization that was generating a bad users isolation (#12128)
* Remove premature optimization that was generating a bad users isolation * fixing tests
Этот коммит содержится в:
коммит произвёл
Miguel de la Cruz
родитель
9094aa7f97
Коммит
3c8665f510
@@ -2151,19 +2151,12 @@ func (a *App) GetViewUsersRestrictions(userId string) (*model.ViewUsersRestricti
|
||||
}
|
||||
|
||||
teamIdsWithPermission := []string{}
|
||||
teamIdsWithoutPermission := []string{}
|
||||
for _, teamId := range teamIds {
|
||||
if a.HasPermissionToTeam(userId, teamId, model.PERMISSION_VIEW_MEMBERS) {
|
||||
teamIdsWithPermission = append(teamIdsWithPermission, teamId)
|
||||
} else {
|
||||
teamIdsWithoutPermission = append(teamIdsWithoutPermission, teamId)
|
||||
}
|
||||
}
|
||||
|
||||
if len(teamIdsWithoutPermission) == 0 {
|
||||
return &model.ViewUsersRestrictions{Teams: teamIdsWithPermission}, nil
|
||||
}
|
||||
|
||||
userChannelMembers, err := a.Srv.Store.Channel().GetAllChannelMembersForUser(userId, true, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -899,7 +899,8 @@ func TestGetViewUsersRestrictions(t *testing.T) {
|
||||
|
||||
assert.NotNil(t, restrictions)
|
||||
assert.NotNil(t, restrictions.Teams)
|
||||
assert.Len(t, restrictions.Channels, 0)
|
||||
assert.NotNil(t, restrictions.Channels)
|
||||
assert.ElementsMatch(t, []string{team1townsquare.Id, team1offtopic.Id, team1channel1.Id, team1channel2.Id, team2townsquare.Id, team2offtopic.Id, team2channel1.Id}, restrictions.Channels)
|
||||
assert.ElementsMatch(t, []string{team1.Id, team2.Id}, restrictions.Teams)
|
||||
})
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user