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