@@ -5,7 +5,7 @@ defmodule MobilizonWeb.Email.Admin do
|
||||
|
||||
use Bamboo.Phoenix, view: MobilizonWeb.EmailView
|
||||
|
||||
import Bamboo.{Email, Phoenix}
|
||||
import Bamboo.Phoenix
|
||||
|
||||
import MobilizonWeb.Gettext
|
||||
|
||||
@@ -19,20 +19,17 @@ defmodule MobilizonWeb.Email.Admin do
|
||||
def report(%User{email: email}, %Report{} = report, locale \\ "en") do
|
||||
Gettext.put_locale(locale)
|
||||
|
||||
instance_url = Config.instance_url()
|
||||
|
||||
subject =
|
||||
gettext(
|
||||
"Mobilizon: New report on instance %{instance}",
|
||||
instance: instance_url
|
||||
"New report on Mobilizon instance %{instance}",
|
||||
instance: Config.instance_name()
|
||||
)
|
||||
|
||||
Email.base_email()
|
||||
|> to(email)
|
||||
|> subject(subject)
|
||||
|> put_header("Reply-To", Config.instance_email_reply_to())
|
||||
Email.base_email(to: email, subject: subject)
|
||||
|> assign(:locale, locale)
|
||||
|> assign(:subject, subject)
|
||||
|> assign(:report, report)
|
||||
|> assign(:instance, instance_url)
|
||||
|> render(:report)
|
||||
|> render("report.html")
|
||||
|> Email.premail()
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,11 +7,24 @@ defmodule MobilizonWeb.Email do
|
||||
|
||||
alias Mobilizon.Config
|
||||
|
||||
@spec base_email :: Bamboo.Email.t()
|
||||
def base_email do
|
||||
new_email()
|
||||
@spec base_email(keyword()) :: Bamboo.Email.t()
|
||||
def base_email(args) do
|
||||
instance = Config.instance_config()
|
||||
|
||||
new_email(args)
|
||||
|> from(Config.instance_email_from())
|
||||
|> put_header("Reply-To", Config.instance_email_reply_to())
|
||||
|> assign(:instance, instance)
|
||||
|> put_html_layout({MobilizonWeb.EmailView, "email.html"})
|
||||
|> put_text_layout({MobilizonWeb.EmailView, "email.text"})
|
||||
|> put_text_layout(false)
|
||||
end
|
||||
|
||||
def premail(email) do
|
||||
html = Premailex.to_inline_css(email.html_body)
|
||||
text = Premailex.to_text(email.html_body)
|
||||
|
||||
email
|
||||
|> html_body(html)
|
||||
|> text_body(text)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,7 +5,7 @@ defmodule MobilizonWeb.Email.User do
|
||||
|
||||
use Bamboo.Phoenix, view: MobilizonWeb.EmailView
|
||||
|
||||
import Bamboo.{Email, Phoenix}
|
||||
import Bamboo.Phoenix
|
||||
|
||||
import MobilizonWeb.Gettext
|
||||
|
||||
@@ -21,21 +21,18 @@ defmodule MobilizonWeb.Email.User do
|
||||
) do
|
||||
Gettext.put_locale(locale)
|
||||
|
||||
instance_url = Config.instance_url()
|
||||
|
||||
subject =
|
||||
gettext(
|
||||
"Mobilizon: Confirmation instructions for %{instance}",
|
||||
instance: instance_url
|
||||
"Instructions to confirm your Mobilizon account on %{instance}",
|
||||
instance: Config.instance_name()
|
||||
)
|
||||
|
||||
Email.base_email()
|
||||
|> to(email)
|
||||
|> subject(subject)
|
||||
|> put_header("Reply-To", Config.instance_email_reply_to())
|
||||
Email.base_email(to: email, subject: subject)
|
||||
|> assign(:locale, locale)
|
||||
|> assign(:token, confirmation_token)
|
||||
|> assign(:instance, instance_url)
|
||||
|> render(:registration_confirmation)
|
||||
|> assign(:subject, subject)
|
||||
|> render("registration_confirmation.html")
|
||||
|> Email.premail()
|
||||
end
|
||||
|
||||
@spec reset_password_email(User.t(), String.t()) :: Bamboo.Email.t()
|
||||
@@ -45,20 +42,17 @@ defmodule MobilizonWeb.Email.User do
|
||||
) do
|
||||
Gettext.put_locale(locale)
|
||||
|
||||
instance_url = Config.instance_url()
|
||||
|
||||
subject =
|
||||
gettext(
|
||||
"Mobilizon: Reset your password on %{instance} instructions",
|
||||
instance: instance_url
|
||||
"Instructions to reset your password on %{instance}",
|
||||
instance: Config.instance_name()
|
||||
)
|
||||
|
||||
Email.base_email()
|
||||
|> to(email)
|
||||
|> subject(subject)
|
||||
|> put_header("Reply-To", Config.instance_email_reply_to())
|
||||
Email.base_email(to: email, subject: subject)
|
||||
|> assign(:locale, locale)
|
||||
|> assign(:token, reset_password_token)
|
||||
|> assign(:instance, instance_url)
|
||||
|> render(:password_reset)
|
||||
|> assign(:subject, subject)
|
||||
|> render("password_reset.html")
|
||||
|> Email.premail()
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user