mirror of
https://git.pleroma.social/sjw/pleroma.git
synced 2024-12-27 21:45:25 +01:00
Admin API: Filter out unapproved users when the active
filter is on
This commit is contained in:
parent
00a4980c61
commit
249f21dcbb
@ -130,6 +130,7 @@ defmodule Pleroma.User.Query do
|
|||||||
defp compose_query({:active, _}, query) do
|
defp compose_query({:active, _}, query) do
|
||||||
User.restrict_deactivated(query)
|
User.restrict_deactivated(query)
|
||||||
|> where([u], not is_nil(u.nickname))
|
|> where([u], not is_nil(u.nickname))
|
||||||
|
|> where([u], u.approval_pending == false)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp compose_query({:legacy_active, _}, query) do
|
defp compose_query({:legacy_active, _}, query) do
|
||||||
|
@ -1164,6 +1164,27 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "`active` filters out users pending approval", %{token: token} do
|
||||||
|
insert(:user, approval_pending: true)
|
||||||
|
%{id: user_id} = insert(:user, approval_pending: false)
|
||||||
|
%{id: admin_id} = token.user
|
||||||
|
|
||||||
|
conn =
|
||||||
|
build_conn()
|
||||||
|
|> assign(:user, token.user)
|
||||||
|
|> assign(:token, token)
|
||||||
|
|> get("/api/pleroma/admin/users?filters=active")
|
||||||
|
|
||||||
|
assert %{
|
||||||
|
"count" => 2,
|
||||||
|
"page_size" => 50,
|
||||||
|
"users" => [
|
||||||
|
%{"id" => ^admin_id},
|
||||||
|
%{"id" => ^user_id}
|
||||||
|
]
|
||||||
|
} = json_response(conn, 200)
|
||||||
|
end
|
||||||
|
|
||||||
test "it works with multiple filters" do
|
test "it works with multiple filters" do
|
||||||
admin = insert(:user, nickname: "john", is_admin: true)
|
admin = insert(:user, nickname: "john", is_admin: true)
|
||||||
token = insert(:oauth_admin_token, user: admin)
|
token = insert(:oauth_admin_token, user: admin)
|
||||||
|
Loading…
Reference in New Issue
Block a user