[MM-26532] Support "active" filter on profile search (#14923)
* Support "active" filter on profile search * Add tests for active user filter
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
bec2f366a7
Коммит
11bc28b5fb
@@ -533,6 +533,7 @@ func getUsers(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
groupConstrained := r.URL.Query().Get("group_constrained")
|
||||
withoutTeam := r.URL.Query().Get("without_team")
|
||||
inactive := r.URL.Query().Get("inactive")
|
||||
active := r.URL.Query().Get("active")
|
||||
role := r.URL.Query().Get("role")
|
||||
sort := r.URL.Query().Get("sort")
|
||||
|
||||
@@ -560,6 +561,11 @@ func getUsers(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
withoutTeamBool, _ := strconv.ParseBool(withoutTeam)
|
||||
groupConstrainedBool, _ := strconv.ParseBool(groupConstrained)
|
||||
inactiveBool, _ := strconv.ParseBool(inactive)
|
||||
activeBool, _ := strconv.ParseBool(active)
|
||||
|
||||
if inactiveBool && activeBool {
|
||||
c.SetInvalidUrlParam("inactive")
|
||||
}
|
||||
|
||||
restrictions, err := c.App.GetViewUsersRestrictions(c.App.Session().UserId)
|
||||
if err != nil {
|
||||
@@ -576,6 +582,7 @@ func getUsers(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
GroupConstrained: groupConstrainedBool,
|
||||
WithoutTeam: withoutTeamBool,
|
||||
Inactive: inactiveBool,
|
||||
Active: activeBool,
|
||||
Role: role,
|
||||
Sort: sort,
|
||||
Page: c.Params.Page,
|
||||
|
||||
@@ -2245,6 +2245,35 @@ func TestGetRecentlyActiveUsersInTeam(t *testing.T) {
|
||||
CheckUnauthorizedStatus(t, resp)
|
||||
}
|
||||
|
||||
func TestGetActiveUsersInTeam(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
teamId := th.BasicTeam.Id
|
||||
|
||||
th.SystemAdminClient.UpdateUserActive(th.BasicUser2.Id, false)
|
||||
rusers, resp := th.Client.GetActiveUsersInTeam(teamId, 0, 60, "")
|
||||
CheckNoError(t, resp)
|
||||
|
||||
require.NotZero(t, len(rusers))
|
||||
for _, u := range rusers {
|
||||
require.Zero(t, u.DeleteAt, "should not be deleted")
|
||||
require.NotEqual(t, th.BasicUser2.Id, "should not include deactivated user")
|
||||
CheckUserSanitization(t, u)
|
||||
}
|
||||
|
||||
rusers, resp = th.Client.GetActiveUsersInTeam(teamId, 0, 1, "")
|
||||
CheckNoError(t, resp)
|
||||
require.Len(t, rusers, 1, "should be 1 per page")
|
||||
|
||||
// Check case where we have supplied both active and inactive flags
|
||||
_, err := th.Client.DoApiGet("/users?inactive=true&active=true", "")
|
||||
require.NotNil(t, err)
|
||||
|
||||
th.Client.Logout()
|
||||
_, resp = th.Client.GetActiveUsersInTeam(teamId, 0, 1, "")
|
||||
CheckUnauthorizedStatus(t, resp)
|
||||
}
|
||||
|
||||
func TestGetUsersWithoutTeam(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Ссылка в новой задаче
Block a user