Improve searching for group actors

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2021-11-06 10:09:54 +01:00
parent 4fc044c595
commit 4de39d5850
8 changed files with 97 additions and 41 deletions

View File

@@ -21,7 +21,14 @@ defmodule Mobilizon.GraphQL.Resolvers.Search do
"""
@spec search_groups(any(), map(), Absinthe.Resolution.t()) ::
{:ok, Page.t(Actor.t())} | {:error, String.t()}
def search_groups(_parent, %{page: page, limit: limit} = args, _resolution) do
def search_groups(
_parent,
%{page: page, limit: limit} = args,
%{context: context} = _resolution
) do
current_actor = Map.get(context, :current_actor, nil)
current_actor_id = if current_actor, do: current_actor.id, else: nil
args = Map.put(args, :current_actor_id, current_actor_id)
Search.search_actors(args, page, limit, :Group)
end