[MM-14751] Adds group_constrained filter to user list and search endpoints (#10678)

Этот коммит содержится в:
Miguel de la Cruz
2019-05-16 10:12:06 +01:00
коммит произвёл GitHub
родитель beb7592c93
Коммит 098dbc84cc
9 изменённых файлов: 206 добавлений и 85 удалений

Просмотреть файл

@@ -452,6 +452,7 @@ func getUsers(c *Context, w http.ResponseWriter, r *http.Request) {
notInTeamId := r.URL.Query().Get("not_in_team")
inChannelId := r.URL.Query().Get("in_channel")
notInChannelId := r.URL.Query().Get("not_in_channel")
groupConstrained := r.URL.Query().Get("group_constrained")
withoutTeam := r.URL.Query().Get("without_team")
inactive := r.URL.Query().Get("inactive")
role := r.URL.Query().Get("role")
@@ -479,6 +480,7 @@ func getUsers(c *Context, w http.ResponseWriter, r *http.Request) {
}
withoutTeamBool, _ := strconv.ParseBool(withoutTeam)
groupConstrainedBool, _ := strconv.ParseBool(groupConstrained)
inactiveBool, _ := strconv.ParseBool(inactive)
restrictions, err := c.App.GetViewUsersRestrictions(c.App.Session.UserId)
@@ -492,6 +494,7 @@ func getUsers(c *Context, w http.ResponseWriter, r *http.Request) {
InChannelId: inChannelId,
NotInTeamId: notInTeamId,
NotInChannelId: notInChannelId,
GroupConstrained: groupConstrainedBool,
WithoutTeam: withoutTeamBool,
Inactive: inactiveBool,
Role: role,
@@ -518,7 +521,7 @@ func getUsers(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
profiles, err = c.App.GetUsersNotInChannelPage(inTeamId, notInChannelId, c.Params.Page, c.Params.PerPage, c.IsSystemAdmin(), restrictions)
profiles, err = c.App.GetUsersNotInChannelPage(inTeamId, notInChannelId, groupConstrainedBool, c.Params.Page, c.Params.PerPage, c.IsSystemAdmin(), restrictions)
} else if len(notInTeamId) > 0 {
if !c.App.SessionHasPermissionToTeam(c.App.Session, notInTeamId, model.PERMISSION_VIEW_TEAM) {
c.SetPermissionError(model.PERMISSION_VIEW_TEAM)
@@ -530,7 +533,7 @@ func getUsers(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
profiles, err = c.App.GetUsersNotInTeamPage(notInTeamId, c.Params.Page, c.Params.PerPage, c.IsSystemAdmin(), restrictions)
profiles, err = c.App.GetUsersNotInTeamPage(notInTeamId, groupConstrainedBool, c.Params.Page, c.Params.PerPage, c.IsSystemAdmin(), restrictions)
} else if len(inTeamId) > 0 {
if !c.App.SessionHasPermissionToTeam(c.App.Session, inTeamId, model.PERMISSION_VIEW_TEAM) {
c.SetPermissionError(model.PERMISSION_VIEW_TEAM)
@@ -673,10 +676,11 @@ func searchUsers(c *Context, w http.ResponseWriter, r *http.Request) {
}
options := &model.UserSearchOptions{
IsAdmin: c.IsSystemAdmin(),
AllowInactive: props.AllowInactive,
Limit: props.Limit,
Role: props.Role,
IsAdmin: c.IsSystemAdmin(),
AllowInactive: props.AllowInactive,
GroupConstrained: props.GroupConstrained,
Limit: props.Limit,
Role: props.Role,
}
if c.App.SessionHasPermissionTo(c.App.Session, model.PERMISSION_MANAGE_SYSTEM) {