diff --git a/app/user.go b/app/user.go index d2566bf5fd..2920eaefa8 100644 --- a/app/user.go +++ b/app/user.go @@ -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 diff --git a/app/user_test.go b/app/user_test.go index f329815221..3f2aac4c06 100644 --- a/app/user_test.go +++ b/app/user_test.go @@ -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) })