version chapril de mobilizon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.7 KiB

defmodule Mobilizon.Web.Email.Actor do
@moduledoc """
Handles emails sent about actors status.
use Phoenix.Swoosh, view: Mobilizon.Web.EmailView
import Mobilizon.Web.Gettext
alias Mobilizon.Actors.Actor
alias Mobilizon.Events.{Event, Participant}
alias Mobilizon.Users
alias Mobilizon.Users.User
alias Mobilizon.Web.Email
@doc """
Send a notification to participants from events organized by an actor that is going to be suspended
@spec send_notification_event_participants_from_suspension(Participant.t(), Actor.t()) ::
def send_notification_event_participants_from_suspension(
actor: %Actor{user_id: nil}
do: :ok
def send_notification_event_participants_from_suspension(%Participant{role: role}, _suspended)
when role not in [:participant, :moderator, :administrator],
do: :ok
def send_notification_event_participants_from_suspension(
actor: %Actor{user_id: user_id},
event: %Event{} = event,
role: member_role
%Actor{} = suspended
) do
with %User{email: email, locale: locale} <- Users.get_user!(user_id) do
subject = gettext("Your participation to %{event} has been cancelled!", event: event.title)
[to: email, subject: subject]
|> Email.base_email()
|> render_body(:actor_suspension_participants, %{
locale: locale,
actor: suspended,
event: event,
role: member_role,
subject: subject
|> Email.Mailer.send_email()