Fix searching for persons
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
3afc7c7feb
commit
5afdd80c71
@ -46,7 +46,7 @@ defmodule Mobilizon.GraphQL.API.Search do
|
||||
actor_type: [result_type],
|
||||
radius: Map.get(args, :radius),
|
||||
location: Map.get(args, :location),
|
||||
minimum_visibility: :public
|
||||
minimum_visibility: Map.get(args, :minimum_visibility, :public)
|
||||
],
|
||||
page,
|
||||
limit
|
||||
|
@ -9,7 +9,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Search do
|
||||
Search persons
|
||||
"""
|
||||
def search_persons(_parent, %{page: page, limit: limit} = args, _resolution) do
|
||||
Search.search_actors(args, page, limit, :Person)
|
||||
Search.search_actors(Map.put(args, :minimum_visibility, :private), page, limit, :Person)
|
||||
end
|
||||
|
||||
@doc """
|
||||
|
@ -500,6 +500,10 @@ defmodule Mobilizon.Actors do
|
||||
defp filter_suspended(query, true), do: where(query, [a], a.suspended)
|
||||
defp filter_suspended(query, false), do: where(query, [a], not a.suspended)
|
||||
|
||||
@spec filter_out_anonymous_actor_id(Ecto.Query.t(), integer() | String.t()) :: Ecto.Query.t()
|
||||
defp filter_out_anonymous_actor_id(query, anonymous_actor_id),
|
||||
do: where(query, [a], a.id != ^anonymous_actor_id)
|
||||
|
||||
@doc """
|
||||
Returns the list of local actors by their username.
|
||||
"""
|
||||
@ -527,12 +531,15 @@ defmodule Mobilizon.Actors do
|
||||
page \\ nil,
|
||||
limit \\ nil
|
||||
) do
|
||||
anonymous_actor_id = Mobilizon.Config.anonymous_actor_id()
|
||||
|
||||
Actor
|
||||
|> actor_by_username_or_name_query(term)
|
||||
|> actors_for_location(Keyword.get(options, :location), Keyword.get(options, :radius))
|
||||
|> filter_by_types(Keyword.get(options, :actor_type, :Group))
|
||||
|> filter_by_minimum_visibility(Keyword.get(options, :minimum_visibility, :public))
|
||||
|> filter_suspended(false)
|
||||
|> filter_out_anonymous_actor_id(anonymous_actor_id)
|
||||
|> Page.build_page(page, limit)
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user