1
0
Fork 0
mirror of https://framagit.org/framasoft/mobilizon.git synced 2024-12-29 11:25:39 +00:00
mobilizon/lib/mobilizon_web/email/admin.ex

35 lines
819 B
Elixir
Raw Normal View History

2019-09-17 00:45:32 +00:00
defmodule MobilizonWeb.Email.Admin do
@moduledoc """
2019-09-07 21:58:53 +00:00
Handles emails sent to admins.
"""
2019-09-17 00:45:32 +00:00
use Bamboo.Phoenix, view: MobilizonWeb.EmailView
2019-09-07 21:58:53 +00:00
import Bamboo.Phoenix
2019-09-07 21:58:53 +00:00
import MobilizonWeb.Gettext
2019-09-07 21:58:53 +00:00
2019-09-17 00:45:32 +00:00
alias Mobilizon.Config
alias Mobilizon.Reports.Report
2019-09-07 21:58:53 +00:00
alias Mobilizon.Users.User
2019-09-17 00:45:32 +00:00
alias MobilizonWeb.Email
2019-09-07 21:58:53 +00:00
@spec report(User.t(), Report.t(), String.t()) :: Bamboo.Email.t()
def report(%User{email: email}, %Report{} = report, locale \\ "en") do
MobilizonWeb.Gettext.put_locale(locale)
2019-09-07 21:58:53 +00:00
subject =
gettext(
"New report on Mobilizon instance %{instance}",
instance: Config.instance_name()
2019-09-07 21:58:53 +00:00
)
Email.base_email(to: email, subject: subject)
|> assign(:locale, locale)
|> assign(:subject, subject)
|> assign(:report, report)
|> render(:report)
end
end