admin user search: added filter by actor_type
This commit is contained in:
parent
46b420aa60
commit
60663150b5
|
@ -56,7 +56,8 @@ defmodule Pleroma.User.Query do
|
|||
ap_id: [String.t()],
|
||||
order_by: term(),
|
||||
select: term(),
|
||||
limit: pos_integer()
|
||||
limit: pos_integer(),
|
||||
actor_types: [String.t()]
|
||||
}
|
||||
| map()
|
||||
|
||||
|
@ -115,6 +116,10 @@ defp compose_query({:is_admin, bool}, query) do
|
|||
where(query, [u], u.is_admin == ^bool)
|
||||
end
|
||||
|
||||
defp compose_query({:actor_types, actor_types}, query) when is_list(actor_types) do
|
||||
where(query, [u], u.actor_type in ^actor_types)
|
||||
end
|
||||
|
||||
defp compose_query({:is_moderator, bool}, query) do
|
||||
where(query, [u], u.is_moderator == ^bool)
|
||||
end
|
||||
|
|
|
@ -143,6 +143,20 @@ test "it returns users with tags" do
|
|||
assert user2 in users
|
||||
end
|
||||
|
||||
test "it returns users by actor_types" do
|
||||
user_service = insert(:user, actor_type: "Service")
|
||||
user_application = insert(:user, actor_type: "Application")
|
||||
user1 = insert(:user)
|
||||
user2 = insert(:user)
|
||||
|
||||
{:ok, [^user_service], 1} = Search.user(%{actor_types: ["Service"]})
|
||||
{:ok, [^user_application], 1} = Search.user(%{actor_types: ["Application"]})
|
||||
{:ok, [^user1, ^user2], 2} = Search.user(%{actor_types: ["Person"]})
|
||||
|
||||
{:ok, [^user_service, ^user1, ^user2], 3} =
|
||||
Search.user(%{actor_types: ["Person", "Service"]})
|
||||
end
|
||||
|
||||
test "it returns user by display name" do
|
||||
user = insert(:user, name: "Display name")
|
||||
insert(:user)
|
||||
|
|
Loading…
Reference in a new issue