Search should return only groups, don't show user profiles
Closes #845 Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
c5d5758ece
commit
264b94e30c
|
@ -94,9 +94,13 @@ defmodule Mobilizon.GraphQL.API.Search do
|
||||||
@spec process_from_username(String.t()) :: Page.t()
|
@spec process_from_username(String.t()) :: Page.t()
|
||||||
defp process_from_username(search) do
|
defp process_from_username(search) do
|
||||||
case ActivityPubActor.find_or_make_actor_from_nickname(search) do
|
case ActivityPubActor.find_or_make_actor_from_nickname(search) do
|
||||||
{:ok, actor} ->
|
{:ok, %Actor{type: :Group} = actor} ->
|
||||||
%Page{total: 1, elements: [actor]}
|
%Page{total: 1, elements: [actor]}
|
||||||
|
|
||||||
|
# Don't return anything else than groups
|
||||||
|
{:ok, %Actor{}} ->
|
||||||
|
%Page{total: 0, elements: []}
|
||||||
|
|
||||||
{:error, _err} ->
|
{:error, _err} ->
|
||||||
Logger.debug(fn -> "Unable to find or make actor '#{search}'" end)
|
Logger.debug(fn -> "Unable to find or make actor '#{search}'" end)
|
||||||
|
|
||||||
|
|
|
@ -16,9 +16,11 @@ defmodule Mobilizon.GraphQL.API.SearchTest do
|
||||||
|
|
||||||
test "search an user by username" do
|
test "search an user by username" do
|
||||||
with_mock ActivityPubActor,
|
with_mock ActivityPubActor,
|
||||||
find_or_make_actor_from_nickname: fn "toto@domain.tld" -> {:ok, %Actor{id: 42}} end do
|
find_or_make_actor_from_nickname: fn "toto@domain.tld" ->
|
||||||
assert {:ok, %Page{total: 1, elements: [%Actor{id: 42}]}} ==
|
{:ok, %Actor{id: 42, type: :Group}}
|
||||||
Search.search_actors(%{term: "toto@domain.tld"}, 1, 10, :Person)
|
end do
|
||||||
|
assert {:ok, %Page{total: 1, elements: [%Actor{id: 42, type: :Group}]}} ==
|
||||||
|
Search.search_actors(%{term: "toto@domain.tld"}, 1, 10, :Group)
|
||||||
|
|
||||||
assert_called(ActivityPubActor.find_or_make_actor_from_nickname("toto@domain.tld"))
|
assert_called(ActivityPubActor.find_or_make_actor_from_nickname("toto@domain.tld"))
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue