mobilizon/lib/service/notifier/email.ex
Thomas Citharel 86c2512c62
WIP
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2021-06-04 13:32:05 +02:00

32 lines
766 B
Elixir

defmodule Mobilizon.Service.Notifier.Email do
@moduledoc """
Email notifier
"""
alias Mobilizon.Activities.Activity
alias Mobilizon.Config
alias Mobilizon.Service.Notifier
alias Mobilizon.Service.Notifier.Email
alias Mobilizon.Users.User
alias Mobilizon.Web.Email.Activity, as: EmailActivity
alias Mobilizon.Web.Email.Mailer
@behaviour Notifier
@impl Notifier
def ready? do
Config.get(__MODULE__, :enabled)
end
@impl Notifier
def send(%User{} = user, %Activity{} = activity) do
Email.send(user, [activity])
end
@impl Notifier
def send(%User{email: email, locale: locale}, activities) when is_list(activities) do
email
|> EmailActivity.direct_activity(activities, locale)
|> Mailer.send_email()
end
end