2018-11-06 09:30:27 +00:00
|
|
|
defmodule MobilizonWeb.Resolvers.Event do
|
2019-01-03 13:59:59 +00:00
|
|
|
@moduledoc """
|
2019-09-22 14:26:23 +00:00
|
|
|
Handles the event-related GraphQL calls.
|
2019-01-03 13:59:59 +00:00
|
|
|
"""
|
2019-09-22 14:26:23 +00:00
|
|
|
|
2020-01-22 23:55:07 +00:00
|
|
|
import Mobilizon.Service.Admin.ActionLog
|
2019-09-22 14:26:23 +00:00
|
|
|
|
|
|
|
alias Mobilizon.Actors
|
2019-09-07 17:54:11 +00:00
|
|
|
alias Mobilizon.Actors.Actor
|
2019-04-11 16:25:32 +00:00
|
|
|
alias Mobilizon.Events
|
2019-10-25 15:43:37 +00:00
|
|
|
alias Mobilizon.Events.{Event, Participant, EventParticipantStats}
|
2019-03-05 16:23:05 +00:00
|
|
|
alias Mobilizon.Users.User
|
2019-09-22 14:26:23 +00:00
|
|
|
|
2020-01-22 01:14:42 +00:00
|
|
|
alias Mobilizon.Federation.ActivityPub.Activity
|
|
|
|
|
2019-09-22 16:29:13 +00:00
|
|
|
alias MobilizonWeb.API
|
2019-05-28 08:51:02 +00:00
|
|
|
alias MobilizonWeb.Resolvers.Person
|
2018-11-07 15:09:28 +00:00
|
|
|
|
2018-12-21 10:45:55 +00:00
|
|
|
# We limit the max number of events that can be retrieved
|
|
|
|
@event_max_limit 100
|
2019-04-11 16:25:32 +00:00
|
|
|
@number_of_related_events 3
|
2018-12-21 10:45:55 +00:00
|
|
|
|
|
|
|
def list_events(_parent, %{page: page, limit: limit}, _resolution)
|
|
|
|
when limit < @event_max_limit do
|
2018-12-14 10:23:36 +00:00
|
|
|
{:ok, Mobilizon.Events.list_events(page, limit)}
|
2018-11-06 09:30:27 +00:00
|
|
|
end
|
|
|
|
|
2018-12-21 11:21:56 +00:00
|
|
|
def list_events(_parent, %{page: _page, limit: _limit}, _resolution) do
|
2018-12-21 10:45:55 +00:00
|
|
|
{:error, :events_max_limit_reached}
|
|
|
|
end
|
|
|
|
|
2019-10-08 16:13:06 +00:00
|
|
|
defp find_private_event(
|
|
|
|
_parent,
|
|
|
|
%{uuid: uuid},
|
|
|
|
%{context: %{current_user: %User{id: user_id}}} = _resolution
|
|
|
|
) do
|
2019-10-02 15:59:07 +00:00
|
|
|
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))}
|
|
|
|
|
|
|
|
{:has_event, _} ->
|
|
|
|
{:error, "Event with UUID #{uuid} not found"}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-10-08 19:31:47 +00:00
|
|
|
defp find_private_event(_parent, %{uuid: uuid}, _resolution),
|
|
|
|
do: {:error, "Event with UUID #{uuid} not found"}
|
|
|
|
|
2019-10-08 16:13:06 +00:00
|
|
|
def find_event(parent, %{uuid: uuid} = args, resolution) do
|
2019-09-18 15:32:37 +00:00
|
|
|
case {:has_event, Mobilizon.Events.get_public_event_by_uuid_with_preload(uuid)} do
|
|
|
|
{:has_event, %Event{} = event} ->
|
2019-05-28 08:51:02 +00:00
|
|
|
{:ok, Map.put(event, :organizer_actor, Person.proxify_pictures(event.organizer_actor))}
|
2019-09-18 15:32:37 +00:00
|
|
|
|
|
|
|
{:has_event, _} ->
|
2019-10-08 16:13:06 +00:00
|
|
|
find_private_event(parent, args, resolution)
|
2018-11-06 09:30:27 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-11-12 22:30:47 +00:00
|
|
|
@doc """
|
|
|
|
List participants for event (through an event request)
|
|
|
|
"""
|
2019-09-20 16:22:03 +00:00
|
|
|
def list_participants_for_event(
|
2019-09-26 14:38:58 +00:00
|
|
|
%Event{id: event_id},
|
|
|
|
%{page: page, limit: limit, roles: roles, actor_id: actor_id},
|
|
|
|
%{context: %{current_user: %User{} = user}} = _resolution
|
2019-09-20 16:22:03 +00:00
|
|
|
) do
|
2019-09-26 14:38:58 +00:00
|
|
|
with {:is_owned, %Actor{} = _actor} <- User.owns_actor(user, actor_id),
|
|
|
|
# Check that moderator has right
|
|
|
|
{:actor_approve_permission, true} <-
|
|
|
|
{:actor_approve_permission, Mobilizon.Events.moderator_for_event?(event_id, actor_id)} do
|
|
|
|
roles =
|
|
|
|
case roles do
|
|
|
|
"" ->
|
|
|
|
[]
|
2019-09-20 16:22:03 +00:00
|
|
|
|
2019-09-26 14:38:58 +00:00
|
|
|
roles ->
|
|
|
|
roles
|
|
|
|
|> String.split(",")
|
|
|
|
|> Enum.map(&String.downcase/1)
|
|
|
|
|> Enum.map(&String.to_existing_atom/1)
|
|
|
|
end
|
|
|
|
|
|
|
|
{:ok, Mobilizon.Events.list_participants_for_event(event_id, roles, page, limit)}
|
|
|
|
else
|
|
|
|
{:is_owned, nil} ->
|
|
|
|
{:error, "Moderator Actor ID is not owned by authenticated user"}
|
|
|
|
|
|
|
|
{:actor_approve_permission, _} ->
|
|
|
|
{:error, "Provided moderator actor ID doesn't have permission on this event"}
|
|
|
|
end
|
|
|
|
end
|
2019-09-20 16:22:03 +00:00
|
|
|
|
2019-09-26 14:38:58 +00:00
|
|
|
def list_participants_for_event(_, _args, _resolution) do
|
|
|
|
{:ok, []}
|
2018-11-12 22:30:47 +00:00
|
|
|
end
|
|
|
|
|
2019-10-25 15:43:37 +00:00
|
|
|
def stats_participants_going(%EventParticipantStats{} = stats, _args, _resolution) do
|
|
|
|
{:ok, stats.participant + stats.moderator + stats.administrator + stats.creator}
|
2019-09-11 14:37:30 +00:00
|
|
|
end
|
|
|
|
|
2019-04-11 16:25:32 +00:00
|
|
|
@doc """
|
|
|
|
List related events
|
|
|
|
"""
|
|
|
|
def list_related_events(
|
2019-04-12 15:00:55 +00:00
|
|
|
%Event{tags: tags, organizer_actor: organizer_actor, uuid: uuid},
|
2019-04-11 16:25:32 +00:00
|
|
|
_args,
|
|
|
|
_resolution
|
|
|
|
) do
|
|
|
|
# We get the organizer's next public event
|
|
|
|
events =
|
2019-09-16 00:07:44 +00:00
|
|
|
[Events.get_upcoming_public_event_for_actor(organizer_actor, uuid)]
|
2019-09-02 15:23:00 +00:00
|
|
|
|> Enum.filter(&is_map/1)
|
2019-04-11 16:25:32 +00:00
|
|
|
|
2019-04-12 15:00:55 +00:00
|
|
|
# We find similar events with the same tags
|
2019-04-11 16:25:32 +00:00
|
|
|
# uniq_by : It's possible event_from_same_actor is inside events_from_tags
|
|
|
|
events =
|
2019-09-07 17:54:11 +00:00
|
|
|
events
|
2019-09-16 00:07:44 +00:00
|
|
|
|> Enum.concat(Events.list_events_by_tags(tags, @number_of_related_events))
|
2019-04-11 16:25:32 +00:00
|
|
|
|> uniq_events()
|
|
|
|
|
|
|
|
# TODO: We should use tag_relations to find more appropriate events
|
|
|
|
|
|
|
|
# We've considered all recommended events, so we fetch the latest events
|
|
|
|
events =
|
|
|
|
if @number_of_related_events - length(events) > 0 do
|
2019-09-07 17:54:11 +00:00
|
|
|
events
|
|
|
|
|> Enum.concat(
|
|
|
|
Events.list_events(1, @number_of_related_events, :begins_on, :asc, true, true)
|
|
|
|
)
|
2019-04-11 16:25:32 +00:00
|
|
|
|> uniq_events()
|
|
|
|
else
|
|
|
|
events
|
|
|
|
end
|
|
|
|
|
|
|
|
events =
|
|
|
|
events
|
|
|
|
# We remove the same event from the results
|
|
|
|
|> Enum.filter(fn event -> event.uuid != uuid end)
|
|
|
|
# We return only @number_of_related_events right now
|
|
|
|
|> Enum.take(@number_of_related_events)
|
|
|
|
|
|
|
|
{:ok, events}
|
|
|
|
end
|
|
|
|
|
2019-04-12 15:00:55 +00:00
|
|
|
defp uniq_events(events), do: Enum.uniq_by(events, fn event -> event.uuid end)
|
|
|
|
|
2019-02-01 14:38:35 +00:00
|
|
|
@doc """
|
|
|
|
Join an event for an actor
|
|
|
|
"""
|
|
|
|
def actor_join_event(
|
|
|
|
_parent,
|
|
|
|
%{actor_id: actor_id, event_id: event_id},
|
2019-09-07 17:54:11 +00:00
|
|
|
%{context: %{current_user: user}}
|
2019-02-01 14:38:35 +00:00
|
|
|
) do
|
2019-09-07 17:54:11 +00:00
|
|
|
with {:is_owned, %Actor{} = actor} <- User.owns_actor(user, actor_id),
|
2019-08-14 15:45:11 +00:00
|
|
|
{:has_event, {:ok, %Event{} = event}} <-
|
2019-09-16 00:07:44 +00:00
|
|
|
{:has_event, Mobilizon.Events.get_event_with_preload(event_id)},
|
2019-02-01 14:38:35 +00:00
|
|
|
{:error, :participant_not_found} <- Mobilizon.Events.get_participant(event_id, actor_id),
|
2019-09-22 16:29:13 +00:00
|
|
|
{:ok, _activity, participant} <- API.Participations.join(event, actor),
|
2019-02-01 14:38:35 +00:00
|
|
|
participant <-
|
2019-09-07 17:54:11 +00:00
|
|
|
participant
|
|
|
|
|> Map.put(:event, event)
|
2019-05-28 08:51:02 +00:00
|
|
|
|> Map.put(:actor, Person.proxify_pictures(actor)) do
|
2019-02-01 14:38:35 +00:00
|
|
|
{:ok, participant}
|
|
|
|
else
|
2019-10-11 09:50:06 +00:00
|
|
|
{:maximum_attendee_capacity, _} ->
|
2019-10-15 19:18:03 +00:00
|
|
|
{:error, "The event has already reached its maximum capacity"}
|
2019-10-11 09:50:06 +00:00
|
|
|
|
2019-08-14 15:45:11 +00:00
|
|
|
{:has_event, _} ->
|
|
|
|
{:error, "Event with this ID #{inspect(event_id)} doesn't exist"}
|
|
|
|
|
2019-09-07 17:54:11 +00:00
|
|
|
{:is_owned, nil} ->
|
2019-02-01 14:38:35 +00:00
|
|
|
{:error, "Actor id is not owned by authenticated user"}
|
|
|
|
|
|
|
|
{:error, :event_not_found} ->
|
|
|
|
{:error, "Event id not found"}
|
|
|
|
|
|
|
|
{:ok, %Participant{}} ->
|
|
|
|
{:error, "You are already a participant of this event"}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def actor_join_event(_parent, _args, _resolution) do
|
|
|
|
{:error, "You need to be logged-in to join an event"}
|
|
|
|
end
|
|
|
|
|
|
|
|
@doc """
|
|
|
|
Leave an event for an actor
|
|
|
|
"""
|
|
|
|
def actor_leave_event(
|
|
|
|
_parent,
|
|
|
|
%{actor_id: actor_id, event_id: event_id},
|
2019-09-07 17:54:11 +00:00
|
|
|
%{context: %{current_user: user}}
|
2019-02-01 14:38:35 +00:00
|
|
|
) do
|
2019-09-07 17:54:11 +00:00
|
|
|
with {:is_owned, %Actor{} = actor} <- User.owns_actor(user, actor_id),
|
2019-08-14 15:45:11 +00:00
|
|
|
{:has_event, {:ok, %Event{} = event}} <-
|
2019-09-16 00:07:44 +00:00
|
|
|
{:has_event, Mobilizon.Events.get_event_with_preload(event_id)},
|
2019-09-22 16:29:13 +00:00
|
|
|
{:ok, _activity, _participant} <- API.Participations.leave(event, actor) do
|
2019-09-07 17:54:11 +00:00
|
|
|
{:ok, %{event: %{id: event_id}, actor: %{id: actor_id}}}
|
2019-02-01 14:38:35 +00:00
|
|
|
else
|
2019-08-14 15:45:11 +00:00
|
|
|
{:has_event, _} ->
|
|
|
|
{:error, "Event with this ID #{inspect(event_id)} doesn't exist"}
|
|
|
|
|
2019-09-07 17:54:11 +00:00
|
|
|
{:is_owned, nil} ->
|
2019-02-01 14:38:35 +00:00
|
|
|
{:error, "Actor id is not owned by authenticated user"}
|
|
|
|
|
2019-02-07 16:57:49 +00:00
|
|
|
{:only_organizer, true} ->
|
|
|
|
{:error, "You can't leave event because you're the only event creator participant"}
|
|
|
|
|
2019-02-01 14:38:35 +00:00
|
|
|
{:error, :participant_not_found} ->
|
|
|
|
{:error, "Participant not found"}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def actor_leave_event(_parent, _args, _resolution) do
|
|
|
|
{:error, "You need to be logged-in to leave an event"}
|
|
|
|
end
|
|
|
|
|
2019-09-30 11:48:47 +00:00
|
|
|
def update_participation(
|
2019-09-20 16:22:03 +00:00
|
|
|
_parent,
|
2019-09-30 11:48:47 +00:00
|
|
|
%{id: participation_id, moderator_actor_id: moderator_actor_id, role: new_role},
|
2019-09-20 16:22:03 +00:00
|
|
|
%{
|
|
|
|
context: %{
|
|
|
|
current_user: user
|
|
|
|
}
|
|
|
|
}
|
|
|
|
) do
|
|
|
|
# Check that moderator provided is rightly authenticated
|
2019-09-22 09:22:16 +00:00
|
|
|
with {:is_owned, moderator_actor} <- User.owns_actor(user, moderator_actor_id),
|
2019-09-20 16:22:03 +00:00
|
|
|
# Check that participation already exists
|
2019-09-30 11:48:47 +00:00
|
|
|
{:has_participation, %Participant{role: old_role} = participation} <-
|
2019-09-20 16:22:03 +00:00
|
|
|
{:has_participation, Mobilizon.Events.get_participant(participation_id)},
|
2019-09-30 11:48:47 +00:00
|
|
|
{:same_role, false} <- {:same_role, new_role == old_role},
|
2019-09-20 16:22:03 +00:00
|
|
|
# Check that moderator has right
|
|
|
|
{:actor_approve_permission, true} <-
|
|
|
|
{:actor_approve_permission,
|
|
|
|
Mobilizon.Events.moderator_for_event?(participation.event.id, moderator_actor_id)},
|
|
|
|
{:ok, _activity, participation} <-
|
2019-09-30 11:48:47 +00:00
|
|
|
MobilizonWeb.API.Participations.update(participation, moderator_actor, new_role) do
|
2019-09-20 16:22:03 +00:00
|
|
|
{:ok, participation}
|
|
|
|
else
|
2019-09-22 09:22:16 +00:00
|
|
|
{:is_owned, nil} ->
|
2019-09-20 16:22:03 +00:00
|
|
|
{:error, "Moderator Actor ID is not owned by authenticated user"}
|
|
|
|
|
|
|
|
{:has_participation, %Participant{role: role, id: id}} ->
|
|
|
|
{:error,
|
|
|
|
"Participant #{id} can't be approved since it's already a participant (with role #{role})"}
|
|
|
|
|
2019-12-03 10:29:51 +00:00
|
|
|
{:has_participation, nil} ->
|
|
|
|
{:error, "Participant not found"}
|
|
|
|
|
2019-09-20 16:22:03 +00:00
|
|
|
{:actor_approve_permission, _} ->
|
|
|
|
{:error, "Provided moderator actor ID doesn't have permission on this event"}
|
|
|
|
|
2019-09-30 11:48:47 +00:00
|
|
|
{:same_role, true} ->
|
|
|
|
{:error, "Participant already has role #{new_role}"}
|
2019-09-20 16:22:03 +00:00
|
|
|
|
2019-09-30 11:48:47 +00:00
|
|
|
{:error, :participant_not_found} ->
|
2019-09-20 16:22:03 +00:00
|
|
|
{:error, "Participant not found"}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-12-14 16:41:55 +00:00
|
|
|
@doc """
|
|
|
|
Create an event
|
|
|
|
"""
|
2019-09-02 15:23:00 +00:00
|
|
|
def create_event(
|
|
|
|
_parent,
|
|
|
|
%{organizer_actor_id: organizer_actor_id} = args,
|
2019-09-07 17:54:11 +00:00
|
|
|
%{context: %{current_user: user}} = _resolution
|
2019-09-02 15:23:00 +00:00
|
|
|
) do
|
2019-09-04 16:24:31 +00:00
|
|
|
# See https://github.com/absinthe-graphql/absinthe/issues/490
|
|
|
|
with args <- Map.put(args, :options, args[:options] || %{}),
|
2019-09-07 17:54:11 +00:00
|
|
|
{:is_owned, %Actor{} = organizer_actor} <- User.owns_actor(user, organizer_actor_id),
|
2019-09-02 15:23:00 +00:00
|
|
|
args_with_organizer <- Map.put(args, :organizer_actor, organizer_actor),
|
2019-09-21 21:59:07 +00:00
|
|
|
{:ok, %Activity{data: %{"object" => %{"type" => "Event"}}}, %Event{} = event} <-
|
2019-09-02 15:23:00 +00:00
|
|
|
MobilizonWeb.API.Events.create_event(args_with_organizer) do
|
2019-07-30 08:35:29 +00:00
|
|
|
{:ok, event}
|
2019-09-02 15:23:00 +00:00
|
|
|
else
|
2019-09-07 17:54:11 +00:00
|
|
|
{:is_owned, nil} ->
|
2019-09-02 15:23:00 +00:00
|
|
|
{:error, "Organizer actor id is not owned by the user"}
|
2019-10-02 15:59:07 +00:00
|
|
|
|
2019-11-18 17:40:03 +00:00
|
|
|
{:error, _, %Ecto.Changeset{} = error, _} ->
|
|
|
|
{:error, error}
|
|
|
|
|
2019-10-02 15:59:07 +00:00
|
|
|
{:error, %Ecto.Changeset{} = error} ->
|
|
|
|
{:error, error}
|
2018-12-14 16:41:55 +00:00
|
|
|
end
|
2018-11-06 09:30:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def create_event(_parent, _args, _resolution) do
|
|
|
|
{:error, "You need to be logged-in to create events"}
|
|
|
|
end
|
2019-01-25 16:06:57 +00:00
|
|
|
|
2019-09-02 15:23:00 +00:00
|
|
|
@doc """
|
|
|
|
Update an event
|
|
|
|
"""
|
|
|
|
def update_event(
|
|
|
|
_parent,
|
|
|
|
%{event_id: event_id} = args,
|
2019-09-07 17:54:11 +00:00
|
|
|
%{context: %{current_user: user}} = _resolution
|
2019-09-02 15:23:00 +00:00
|
|
|
) do
|
2019-09-04 16:24:31 +00:00
|
|
|
# See https://github.com/absinthe-graphql/absinthe/issues/490
|
|
|
|
with args <- Map.put(args, :options, args[:options] || %{}),
|
2019-09-21 21:59:07 +00:00
|
|
|
{:ok, %Event{} = event} <- Events.get_event_with_preload(event_id),
|
2019-11-18 15:06:24 +00:00
|
|
|
organizer_actor_id <- args |> Map.get(:organizer_actor_id, event.organizer_actor_id),
|
2019-09-07 17:54:11 +00:00
|
|
|
{:is_owned, %Actor{} = organizer_actor} <-
|
2019-11-18 15:06:24 +00:00
|
|
|
User.owns_actor(user, organizer_actor_id),
|
2019-09-09 09:21:42 +00:00
|
|
|
args <- Map.put(args, :organizer_actor, organizer_actor),
|
2019-09-21 21:59:07 +00:00
|
|
|
{:ok, %Activity{data: %{"object" => %{"type" => "Event"}}}, %Event{} = event} <-
|
2019-09-04 16:24:31 +00:00
|
|
|
MobilizonWeb.API.Events.update_event(args, event) do
|
2019-09-02 15:23:00 +00:00
|
|
|
{:ok, event}
|
|
|
|
else
|
|
|
|
{:error, :event_not_found} ->
|
|
|
|
{:error, "Event not found"}
|
2019-09-04 16:24:31 +00:00
|
|
|
|
2019-09-07 17:54:11 +00:00
|
|
|
{:is_owned, nil} ->
|
2019-09-04 16:24:31 +00:00
|
|
|
{:error, "User doesn't own actor"}
|
2019-11-18 17:40:03 +00:00
|
|
|
|
|
|
|
{:error, _, %Ecto.Changeset{} = error, _} ->
|
|
|
|
{:error, error}
|
2019-09-02 15:23:00 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def update_event(_parent, _args, _resolution) do
|
|
|
|
{:error, "You need to be logged-in to update an event"}
|
|
|
|
end
|
|
|
|
|
2019-01-25 16:06:57 +00:00
|
|
|
@doc """
|
|
|
|
Delete an event
|
|
|
|
"""
|
2019-09-02 15:23:00 +00:00
|
|
|
def delete_event(
|
|
|
|
_parent,
|
|
|
|
%{event_id: event_id, actor_id: actor_id},
|
2019-09-21 21:59:07 +00:00
|
|
|
%{context: %{current_user: %User{role: role} = user}}
|
2019-09-02 15:23:00 +00:00
|
|
|
) do
|
2019-09-21 21:59:07 +00:00
|
|
|
with {:ok, %Event{local: is_local} = event} <- Events.get_event_with_preload(event_id),
|
2019-09-09 07:31:08 +00:00
|
|
|
{actor_id, ""} <- Integer.parse(actor_id),
|
2019-09-21 21:59:07 +00:00
|
|
|
{:is_owned, %Actor{}} <- User.owns_actor(user, actor_id) do
|
2019-09-09 07:31:08 +00:00
|
|
|
cond do
|
2019-09-21 21:59:07 +00:00
|
|
|
{:event_can_be_managed, true} == Event.can_be_managed_by(event, actor_id) ->
|
2019-09-09 07:31:08 +00:00
|
|
|
do_delete_event(event)
|
|
|
|
|
|
|
|
role in [:moderator, :administrator] ->
|
|
|
|
with {:ok, res} <- do_delete_event(event, !is_local),
|
|
|
|
%Actor{} = actor <- Actors.get_actor(actor_id) do
|
|
|
|
log_action(actor, "delete", event)
|
2019-09-21 21:59:07 +00:00
|
|
|
|
2019-09-09 07:31:08 +00:00
|
|
|
{:ok, res}
|
|
|
|
end
|
|
|
|
|
|
|
|
true ->
|
|
|
|
{:error, "You cannot delete this event"}
|
|
|
|
end
|
2019-01-25 16:06:57 +00:00
|
|
|
else
|
|
|
|
{:error, :event_not_found} ->
|
|
|
|
{:error, "Event not found"}
|
|
|
|
|
2019-09-07 17:54:11 +00:00
|
|
|
{:is_owned, nil} ->
|
2019-01-25 16:06:57 +00:00
|
|
|
{:error, "Actor id is not owned by authenticated user"}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def delete_event(_parent, _args, _resolution) do
|
|
|
|
{:error, "You need to be logged-in to delete an event"}
|
|
|
|
end
|
2019-09-09 07:31:08 +00:00
|
|
|
|
|
|
|
defp do_delete_event(event, federate \\ true) when is_boolean(federate) do
|
|
|
|
with {:ok, _activity, event} <- MobilizonWeb.API.Events.delete_event(event) do
|
|
|
|
{:ok, %{id: event.id}}
|
|
|
|
end
|
|
|
|
end
|
2018-11-06 09:30:27 +00:00
|
|
|
end
|