2019-09-17 02:45:32 +02:00
|
|
|
defmodule MobilizonWeb.Email.Admin do
|
2019-07-23 13:49:22 +02:00
|
|
|
@moduledoc """
|
2019-09-07 23:58:53 +02:00
|
|
|
Handles emails sent to admins.
|
2019-07-23 13:49:22 +02:00
|
|
|
"""
|
|
|
|
|
2019-09-17 02:45:32 +02:00
|
|
|
use Bamboo.Phoenix, view: MobilizonWeb.EmailView
|
2019-09-07 23:58:53 +02:00
|
|
|
|
2019-09-23 19:33:58 +02:00
|
|
|
import Bamboo.Phoenix
|
2019-09-07 23:58:53 +02:00
|
|
|
|
2019-07-23 13:49:22 +02:00
|
|
|
import MobilizonWeb.Gettext
|
2019-09-07 23:58:53 +02:00
|
|
|
|
2019-09-17 02:45:32 +02:00
|
|
|
alias Mobilizon.Config
|
2019-07-23 13:49:22 +02:00
|
|
|
alias Mobilizon.Reports.Report
|
2019-09-07 23:58:53 +02:00
|
|
|
alias Mobilizon.Users.User
|
2019-07-23 13:49:22 +02:00
|
|
|
|
2019-09-17 02:45:32 +02:00
|
|
|
alias MobilizonWeb.Email
|
|
|
|
|
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
|
2019-10-01 13:08:09 +02:00
|
|
|
MobilizonWeb.Gettext.put_locale(locale)
|
2019-07-23 13:49:22 +02:00
|
|
|
|
2019-09-07 23:58:53 +02:00
|
|
|
subject =
|
|
|
|
gettext(
|
2019-09-23 19:33:58 +02:00
|
|
|
"New report on Mobilizon instance %{instance}",
|
|
|
|
instance: Config.instance_name()
|
2019-09-07 23:58:53 +02:00
|
|
|
)
|
|
|
|
|
2019-09-23 19:33:58 +02:00
|
|
|
Email.base_email(to: email, subject: subject)
|
|
|
|
|> assign(:locale, locale)
|
|
|
|
|> assign(:subject, subject)
|
2019-07-23 13:49:22 +02:00
|
|
|
|> assign(:report, report)
|
2019-09-24 12:09:43 +02:00
|
|
|
|> render(:report)
|
2019-07-23 13:49:22 +02:00
|
|
|
end
|
|
|
|
end
|