Properly handle account deleted

Close #191

Also fix an issue with public events not being accessible when requested
as another logged-in user.

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2019-10-08 18:13:06 +02:00
parent 3a133b946f
commit bff00dea21
2 changed files with 15 additions and 8 deletions

View File

@@ -31,11 +31,11 @@ defmodule MobilizonWeb.Resolvers.Event do
{:error, :events_max_limit_reached}
end
def find_event(
_parent,
%{uuid: uuid},
%{context: %{current_user: %User{id: user_id}}} = _resolution
) do
defp find_private_event(
_parent,
%{uuid: uuid},
%{context: %{current_user: %User{id: user_id}}} = _resolution
) do
case {:has_event, Mobilizon.Events.get_own_event_by_uuid_with_preload(uuid, user_id)} do
{:has_event, %Event{} = event} ->
{:ok, Map.put(event, :organizer_actor, Person.proxify_pictures(event.organizer_actor))}
@@ -45,13 +45,13 @@ defmodule MobilizonWeb.Resolvers.Event do
end
end
def find_event(_parent, %{uuid: uuid}, _resolution) do
def find_event(parent, %{uuid: uuid} = args, resolution) do
case {:has_event, Mobilizon.Events.get_public_event_by_uuid_with_preload(uuid)} do
{:has_event, %Event{} = event} ->
{:ok, Map.put(event, :organizer_actor, Person.proxify_pictures(event.organizer_actor))}
{:has_event, _} ->
{:error, "Event with UUID #{uuid} not found"}
find_private_event(parent, args, resolution)
end
end