diff options
Diffstat (limited to 'app/user.go')
-rw-r--r-- | app/user.go | 58 |
1 files changed, 47 insertions, 11 deletions
diff --git a/app/user.go b/app/user.go index d1ddceb23..d01ce7a51 100644 --- a/app/user.go +++ b/app/user.go @@ -1183,31 +1183,49 @@ func VerifyUserEmail(userId string) *model.AppError { return nil } -func SearchUsersInChannel(channelId string, term string, searchOptions map[string]bool) ([]*model.User, *model.AppError) { +func SearchUsersInChannel(channelId string, term string, searchOptions map[string]bool, asAdmin bool) ([]*model.User, *model.AppError) { if result := <-Srv.Store.User().SearchInChannel(channelId, term, searchOptions); result.Err != nil { return nil, result.Err } else { - return result.Data.([]*model.User), nil + users := result.Data.([]*model.User) + + for _, user := range users { + SanitizeProfile(user, asAdmin) + } + + return users, nil } } -func SearchUsersNotInChannel(teamId string, channelId string, term string, searchOptions map[string]bool) ([]*model.User, *model.AppError) { +func SearchUsersNotInChannel(teamId string, channelId string, term string, searchOptions map[string]bool, asAdmin bool) ([]*model.User, *model.AppError) { if result := <-Srv.Store.User().SearchNotInChannel(teamId, channelId, term, searchOptions); result.Err != nil { return nil, result.Err } else { - return result.Data.([]*model.User), nil + users := result.Data.([]*model.User) + + for _, user := range users { + SanitizeProfile(user, asAdmin) + } + + return users, nil } } -func SearchUsersInTeam(teamId string, term string, searchOptions map[string]bool) ([]*model.User, *model.AppError) { +func SearchUsersInTeam(teamId string, term string, searchOptions map[string]bool, asAdmin bool) ([]*model.User, *model.AppError) { if result := <-Srv.Store.User().Search(teamId, term, searchOptions); result.Err != nil { return nil, result.Err } else { - return result.Data.([]*model.User), nil + users := result.Data.([]*model.User) + + for _, user := range users { + SanitizeProfile(user, asAdmin) + } + + return users, nil } } -func AutocompleteUsersInChannel(teamId string, channelId string, term string, searchOptions map[string]bool) (*model.UserAutocompleteInChannel, *model.AppError) { +func AutocompleteUsersInChannel(teamId string, channelId string, term string, searchOptions map[string]bool, asAdmin bool) (*model.UserAutocompleteInChannel, *model.AppError) { uchan := Srv.Store.User().SearchInChannel(channelId, term, searchOptions) nuchan := Srv.Store.User().SearchNotInChannel(teamId, channelId, term, searchOptions) @@ -1216,25 +1234,43 @@ func AutocompleteUsersInChannel(teamId string, channelId string, term string, se if result := <-uchan; result.Err != nil { return nil, result.Err } else { - autocomplete.InChannel = result.Data.([]*model.User) + users := result.Data.([]*model.User) + + for _, user := range users { + SanitizeProfile(user, asAdmin) + } + + autocomplete.InChannel = users } if result := <-nuchan; result.Err != nil { return nil, result.Err } else { - autocomplete.OutOfChannel = result.Data.([]*model.User) + users := result.Data.([]*model.User) + + for _, user := range users { + SanitizeProfile(user, asAdmin) + } + + autocomplete.OutOfChannel = users } return autocomplete, nil } -func AutocompleteUsersInTeam(teamId string, term string, searchOptions map[string]bool) (*model.UserAutocompleteInTeam, *model.AppError) { +func AutocompleteUsersInTeam(teamId string, term string, searchOptions map[string]bool, asAdmin bool) (*model.UserAutocompleteInTeam, *model.AppError) { autocomplete := &model.UserAutocompleteInTeam{} if result := <-Srv.Store.User().Search(teamId, term, searchOptions); result.Err != nil { return nil, result.Err } else { - autocomplete.InTeam = result.Data.([]*model.User) + users := result.Data.([]*model.User) + + for _, user := range users { + SanitizeProfile(user, asAdmin) + } + + autocomplete.InTeam = users } return autocomplete, nil |