From 9e41bc1ad633a82da8b8d318991c0df34425f205 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Mon, 4 Dec 2023 09:02:38 +0100 Subject: [PATCH] fix(backend): only send suspension notification emails when actor's suspended and not just deleted Signed-off-by: Thomas Citharel --- lib/service/actor_suspension.ex | 14 +++++++++----- lib/service/workers/background.ex | 5 ++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/service/actor_suspension.ex b/lib/service/actor_suspension.ex index 00062563e..6c548772a 100644 --- a/lib/service/actor_suspension.ex +++ b/lib/service/actor_suspension.ex @@ -35,13 +35,17 @@ defmodule Mobilizon.Service.ActorSuspension do delete_actor_options = Keyword.merge(@delete_actor_default_options, options) Logger.debug(inspect(delete_actor_options)) - send_suspension_notification(actor) + # Only send suspension notifications if we actually are suspending the actor + if Keyword.get(delete_actor_options, :suspension, false) do + send_suspension_notification(actor) - Logger.debug( - "Sending suspension notifications to participants from events created by this actor" - ) + Logger.debug( + "Sending suspension notifications to participants from events created by this actor" + ) + + notify_event_participants_from_suspension(actor) + end - notify_event_participants_from_suspension(actor) delete_participations(actor) multi = diff --git a/lib/service/workers/background.ex b/lib/service/workers/background.ex index 6f5175b9d..d7d62a0bc 100644 --- a/lib/service/workers/background.ex +++ b/lib/service/workers/background.ex @@ -20,7 +20,10 @@ defmodule Mobilizon.Service.Workers.Background do reserve_username when is_boolean(reserve_username) -> case Actors.get_actor(actor_id) do %Actor{} = actor -> - ActorSuspension.suspend_actor(actor, reserve_username: reserve_username) + ActorSuspension.suspend_actor(actor, + reserve_username: reserve_username, + suspension: Map.get(args, "suspension", false) + ) nil -> {:error, :actor_not_found}