Implement POST /users/search endpoint for APIv4 (#5822)
* Implement POST /users/search endpoint for APIv4 * PLT-2713 Added store functions for searching users that don't have a team * PLT-2713 Added 'without_team' option when searching users * PLT-2713 Added 'without_team' option when searching users (v4)
Этот коммит содержится в:
коммит произвёл
George Goldberg
родитель
7e2e823884
Коммит
2a753949f1
26
app/user.go
26
app/user.go
@@ -1211,6 +1211,18 @@ func VerifyUserEmail(userId string) *model.AppError {
|
||||
return nil
|
||||
}
|
||||
|
||||
func SearchUsers(props *model.UserSearch, searchOptions map[string]bool, asAdmin bool) ([]*model.User, *model.AppError) {
|
||||
if props.WithoutTeam {
|
||||
return SearchUsersWithoutTeam(props.Term, searchOptions, asAdmin)
|
||||
} else if props.InChannelId != "" {
|
||||
return SearchUsersInChannel(props.InChannelId, props.Term, searchOptions, asAdmin)
|
||||
} else if props.NotInChannelId != "" {
|
||||
return SearchUsersNotInChannel(props.TeamId, props.NotInChannelId, props.Term, searchOptions, asAdmin)
|
||||
} else {
|
||||
return SearchUsersInTeam(props.TeamId, props.Term, searchOptions, asAdmin)
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
@@ -1253,6 +1265,20 @@ func SearchUsersInTeam(teamId string, term string, searchOptions map[string]bool
|
||||
}
|
||||
}
|
||||
|
||||
func SearchUsersWithoutTeam(term string, searchOptions map[string]bool, asAdmin bool) ([]*model.User, *model.AppError) {
|
||||
if result := <-Srv.Store.User().SearchWithoutTeam(term, searchOptions); result.Err != nil {
|
||||
return nil, result.Err
|
||||
} else {
|
||||
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, asAdmin bool) (*model.UserAutocompleteInChannel, *model.AppError) {
|
||||
uchan := Srv.Store.User().SearchInChannel(channelId, term, searchOptions)
|
||||
nuchan := Srv.Store.User().SearchNotInChannel(teamId, channelId, term, searchOptions)
|
||||
|
||||
Ссылка в новой задаче
Block a user