Delete participations after warning participants

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2021-09-30 15:57:16 +02:00
parent 98b840190d
commit 2b808d998e
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773

View file

@ -40,7 +40,6 @@ defmodule Mobilizon.Service.ActorSuspension do
)
notify_event_participants_from_suspension(actor)
Logger.debug("Delete participations from events created by this actor")
delete_participations(actor)
multi =
@ -126,7 +125,11 @@ defmodule Mobilizon.Service.ActorSuspension do
|> Enum.filter(fn %Participant{actor: %Actor{id: participant_actor_id}} ->
participant_actor_id != actor_id
end)
|> Enum.each(&ActorEmail.send_notification_event_participants_from_suspension(&1, actor))
|> Enum.map(fn %Participant{} = participant ->
ActorEmail.send_notification_event_participants_from_suspension(participant, actor)
participant
end)
|> Enum.each(&Events.delete_participant/1)
end
@spec get_actor_organizer_events_participations(Actor.t()) :: Ecto.Query.t()
@ -191,6 +194,7 @@ defmodule Mobilizon.Service.ActorSuspension do
@spec delete_participations(Actor.t()) :: :ok
defp delete_participations(%Actor{type: :Person} = actor) do
Logger.debug("Delete participations from events created by this actor")
%Actor{participations: participations} = Repo.preload(actor, [:participations])
Enum.each(participations, &Events.delete_participant/1)
end