From 2b808d998e1e87b01e7431f7addba2c0a4ecdf88 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Thu, 30 Sep 2021 15:57:16 +0200 Subject: [PATCH] Delete participations after warning participants Signed-off-by: Thomas Citharel --- lib/service/actor_suspension.ex | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/service/actor_suspension.ex b/lib/service/actor_suspension.ex index 0472968fe..17d3b7492 100644 --- a/lib/service/actor_suspension.ex +++ b/lib/service/actor_suspension.ex @@ -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