mobilizon.chapril.org-mobil.../lib/web/email/admin.ex

35 lines
821 B
Elixir
Raw Normal View History

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