[GH-7494] Added the role to the user search filter (#9976)
* 7494 added the role to the user search filter * 7494 changed the getUser function to accept the options * added the role filter for the getAllProfiles method * 7494 added the Inactive filter for AllProfiles * 7494 refactored the where clause generation * 7494 added the roles and inactive filters for inTeam Query * 7494 fixed the review comments
Этот коммит содержится в:
коммит произвёл
George Goldberg
родитель
09a519799f
Коммит
bbee234af0
24
api4/user.go
24
api4/user.go
@@ -365,6 +365,8 @@ func getUsers(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
inChannelId := r.URL.Query().Get("in_channel")
|
||||
notInChannelId := r.URL.Query().Get("not_in_channel")
|
||||
withoutTeam := r.URL.Query().Get("without_team")
|
||||
inactive := r.URL.Query().Get("inactive")
|
||||
role := r.URL.Query().Get("role")
|
||||
sort := r.URL.Query().Get("sort")
|
||||
|
||||
if len(notInChannelId) > 0 && len(inTeamId) == 0 {
|
||||
@@ -388,6 +390,22 @@ func getUsers(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
withoutTeamBool, _ := strconv.ParseBool(withoutTeam)
|
||||
inactiveBool, _ := strconv.ParseBool(inactive)
|
||||
|
||||
userGetOptions := &model.UserGetOptions{
|
||||
InTeamId: inTeamId,
|
||||
InChannelId: inChannelId,
|
||||
NotInTeamId: notInTeamId,
|
||||
NotInChannelId: notInChannelId,
|
||||
WithoutTeam: withoutTeamBool,
|
||||
Inactive: inactiveBool,
|
||||
Role: role,
|
||||
Sort: sort,
|
||||
Page: c.Params.Page,
|
||||
PerPage: c.Params.PerPage,
|
||||
}
|
||||
|
||||
var profiles []*model.User
|
||||
var err *model.AppError
|
||||
etag := ""
|
||||
@@ -434,8 +452,7 @@ func getUsers(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
if c.HandleEtag(etag, "Get Users in Team", w, r) {
|
||||
return
|
||||
}
|
||||
|
||||
profiles, err = c.App.GetUsersInTeamPage(inTeamId, c.Params.Page, c.Params.PerPage, c.IsSystemAdmin())
|
||||
profiles, err = c.App.GetUsersInTeamPage(userGetOptions, c.IsSystemAdmin())
|
||||
}
|
||||
} else if len(inChannelId) > 0 {
|
||||
if !c.App.SessionHasPermissionToChannel(c.App.Session, inChannelId, model.PERMISSION_READ_CHANNEL) {
|
||||
@@ -454,7 +471,7 @@ func getUsers(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
if c.HandleEtag(etag, "Get Users", w, r) {
|
||||
return
|
||||
}
|
||||
profiles, err = c.App.GetUsersPage(c.Params.Page, c.Params.PerPage, c.IsSystemAdmin())
|
||||
profiles, err = c.App.GetUsersPage(userGetOptions, c.IsSystemAdmin())
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
@@ -553,6 +570,7 @@ func searchUsers(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
IsAdmin: c.IsSystemAdmin(),
|
||||
AllowInactive: props.AllowInactive,
|
||||
Limit: props.Limit,
|
||||
Role: props.Role,
|
||||
}
|
||||
|
||||
if c.App.SessionHasPermissionTo(c.App.Session, model.PERMISSION_MANAGE_SYSTEM) {
|
||||
|
||||
Ссылка в новой задаче
Block a user