Avoid showing suspended broken UI for suspended/deleted groups

Don't return them if they're suspended

Closes #655

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2021-04-16 18:36:52 +02:00
parent fb821ac455
commit 489787ceb5
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773

View File

@ -26,7 +26,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Group do
} }
} }
) do ) do
with {:group, {:ok, %Actor{id: group_id} = group}} <- with {:group, {:ok, %Actor{id: group_id, suspended: false} = group}} <-
{:group, ActivityPub.find_or_make_group_from_nickname(name)}, {:group, ActivityPub.find_or_make_group_from_nickname(name)},
{:actor, %Actor{id: actor_id} = _actor} <- {:actor, Users.get_actor_for_user(user)}, {:actor, %Actor{id: actor_id} = _actor} <- {:actor, Users.get_actor_for_user(user)},
{:member, true} <- {:member, Actors.is_member?(actor_id, group_id)} do {:member, true} <- {:member, Actors.is_member?(actor_id, group_id)} do
@ -44,7 +44,8 @@ defmodule Mobilizon.GraphQL.Resolvers.Group do
end end
def find_group(_parent, %{preferred_username: name}, _resolution) do def find_group(_parent, %{preferred_username: name}, _resolution) do
with {:ok, actor} <- ActivityPub.find_or_make_group_from_nickname(name), with {:ok, %Actor{suspended: false} = actor} <-
ActivityPub.find_or_make_group_from_nickname(name),
%Actor{} = actor <- restrict_fields_for_non_member_request(actor) do %Actor{} = actor <- restrict_fields_for_non_member_request(actor) do
{:ok, actor} {:ok, actor}
else else