Move mailer from Bamboo to Swoosh
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -2,9 +2,8 @@ defmodule Mobilizon.Web.Email.Participation do
|
||||
@moduledoc """
|
||||
Handles emails sent about participation.
|
||||
"""
|
||||
use Bamboo.Phoenix, view: Mobilizon.Web.EmailView
|
||||
use Phoenix.Swoosh, view: Mobilizon.Web.EmailView
|
||||
|
||||
import Bamboo.Phoenix
|
||||
import Mobilizon.Web.Gettext
|
||||
|
||||
alias Mobilizon.Actors.Actor
|
||||
@@ -28,7 +27,7 @@ defmodule Mobilizon.Web.Email.Participation do
|
||||
|
||||
email
|
||||
|> participation_updated(participation, locale)
|
||||
|> Email.Mailer.send_email_later()
|
||||
|> Email.Mailer.send_email()
|
||||
end
|
||||
|
||||
:ok
|
||||
@@ -40,14 +39,14 @@ defmodule Mobilizon.Web.Email.Participation do
|
||||
with %User{locale: locale} = user <- Users.get_user!(user_id) do
|
||||
user
|
||||
|> participation_updated(participation, locale)
|
||||
|> Email.Mailer.send_email_later()
|
||||
|> Email.Mailer.send_email()
|
||||
|
||||
:ok
|
||||
end
|
||||
end
|
||||
|
||||
@spec participation_updated(String.t() | User.t(), Participant.t(), String.t()) ::
|
||||
Bamboo.Email.t()
|
||||
Swoosh.Email.t()
|
||||
def participation_updated(user, participant, locale \\ "en")
|
||||
|
||||
def participation_updated(
|
||||
@@ -70,12 +69,14 @@ defmodule Mobilizon.Web.Email.Participation do
|
||||
title: event.title
|
||||
)
|
||||
|
||||
Email.base_email(to: email, subject: subject)
|
||||
|> assign(:locale, locale)
|
||||
|> assign(:event, event)
|
||||
|> assign(:jsonLDMetadata, json_ld(participant))
|
||||
|> assign(:subject, subject)
|
||||
|> render(:event_participation_rejected)
|
||||
[to: email, subject: subject]
|
||||
|> Email.base_email()
|
||||
|> render_body(:event_participation_rejected, %{
|
||||
locale: locale,
|
||||
event: event,
|
||||
jsonLDMetadata: json_ld(participant),
|
||||
subject: subject
|
||||
})
|
||||
end
|
||||
|
||||
def participation_updated(
|
||||
@@ -92,12 +93,14 @@ defmodule Mobilizon.Web.Email.Participation do
|
||||
title: event.title
|
||||
)
|
||||
|
||||
Email.base_email(to: email, subject: subject)
|
||||
|> assign(:locale, locale)
|
||||
|> assign(:event, event)
|
||||
|> assign(:subject, subject)
|
||||
|> assign(:jsonLDMetadata, json_ld(participant))
|
||||
|> render(:event_participation_confirmed)
|
||||
[to: email, subject: subject]
|
||||
|> Email.base_email()
|
||||
|> render_body(:event_participation_confirmed, %{
|
||||
locale: locale,
|
||||
event: event,
|
||||
jsonLDMetadata: json_ld(participant),
|
||||
subject: subject
|
||||
})
|
||||
end
|
||||
|
||||
def participation_updated(
|
||||
@@ -113,17 +116,19 @@ defmodule Mobilizon.Web.Email.Participation do
|
||||
title: event.title
|
||||
)
|
||||
|
||||
Email.base_email(to: email, subject: subject)
|
||||
|> assign(:locale, locale)
|
||||
|> assign(:event, event)
|
||||
|> assign(:subject, subject)
|
||||
|> assign(:jsonLDMetadata, json_ld(participant))
|
||||
[to: email, subject: subject]
|
||||
|> Email.base_email()
|
||||
|> Email.add_event_attachment(event)
|
||||
|> render(:event_participation_approved)
|
||||
|> render_body(:event_participation_approved, %{
|
||||
locale: locale,
|
||||
event: event,
|
||||
jsonLDMetadata: json_ld(participant),
|
||||
subject: subject
|
||||
})
|
||||
end
|
||||
|
||||
@spec anonymous_participation_confirmation(String.t(), Participant.t(), String.t()) ::
|
||||
Bamboo.Email.t()
|
||||
Swoosh.Email.t()
|
||||
def anonymous_participation_confirmation(
|
||||
email,
|
||||
%Participant{event: event, role: :not_confirmed} = participant,
|
||||
@@ -137,12 +142,15 @@ defmodule Mobilizon.Web.Email.Participation do
|
||||
title: event.title
|
||||
)
|
||||
|
||||
Email.base_email(to: email, subject: subject)
|
||||
|> assign(:locale, locale)
|
||||
|> assign(:participant, participant)
|
||||
|> assign(:jsonLDMetadata, json_ld(participant))
|
||||
|> assign(:subject, subject)
|
||||
|> render(:anonymous_participation_confirmation)
|
||||
[to: email, subject: subject]
|
||||
|> Email.base_email()
|
||||
|> render_body(:anonymous_participation_confirmation, %{
|
||||
locale: locale,
|
||||
event: event,
|
||||
jsonLDMetadata: json_ld(participant),
|
||||
participant: participant,
|
||||
subject: subject
|
||||
})
|
||||
end
|
||||
|
||||
defp json_ld(participant) do
|
||||
|
||||
Reference in New Issue
Block a user