mirror of
https://framagit.org/framasoft/mobilizon.git
synced 2024-12-23 00:14:48 +00:00
a670a7d7a7
- Refactor plugs to detect and set language - Translate ecto validation errors - Use Gettext directly, not Mobilizon.Web.Gettext - Set the language in the <html> attribute according to the one loaded on front-end Signed-off-by: Thomas Citharel <tcit@tcit.fr>
35 lines
877 B
Elixir
35 lines
877 B
Elixir
defmodule Mobilizon.Web.Email.Admin do
|
|
@moduledoc """
|
|
Handles emails sent to admins.
|
|
"""
|
|
|
|
use Bamboo.Phoenix, view: Mobilizon.Web.EmailView
|
|
|
|
import Bamboo.Phoenix
|
|
|
|
import Mobilizon.Web.Gettext
|
|
|
|
alias Mobilizon.Config
|
|
alias Mobilizon.Reports.Report
|
|
alias Mobilizon.Users.User
|
|
|
|
alias Mobilizon.Web.Email
|
|
|
|
@spec report(User.t(), Report.t(), String.t()) :: Bamboo.Email.t()
|
|
def report(%User{email: email} = user, %Report{} = report, default_locale \\ "en") do
|
|
locale = Map.get(user, :locale, default_locale)
|
|
Gettext.put_locale(locale)
|
|
|
|
subject =
|
|
gettext(
|
|
"New report on Mobilizon instance %{instance}",
|
|
instance: Config.instance_name()
|
|
)
|
|
|
|
Email.base_email(to: email, subject: subject)
|
|
|> assign(:locale, locale)
|
|
|> assign(:subject, subject)
|
|
|> assign(:report, report)
|
|
|> render(:report)
|
|
end
|
|
end
|