Improve the way the instance name is injected into emails
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
6edeeef9a9
commit
4a7c6a861e
@ -8,8 +8,8 @@ defmodule Mobilizon.Web.Email.Actor do
|
|||||||
import Mobilizon.Web.Gettext
|
import Mobilizon.Web.Gettext
|
||||||
|
|
||||||
alias Mobilizon.Actors.Actor
|
alias Mobilizon.Actors.Actor
|
||||||
alias Mobilizon.{Config, Users}
|
|
||||||
alias Mobilizon.Events.{Event, Participant}
|
alias Mobilizon.Events.{Event, Participant}
|
||||||
|
alias Mobilizon.Users
|
||||||
alias Mobilizon.Users.User
|
alias Mobilizon.Users.User
|
||||||
alias Mobilizon.Web.Email
|
alias Mobilizon.Web.Email
|
||||||
|
|
||||||
@ -40,7 +40,6 @@ defmodule Mobilizon.Web.Email.Actor do
|
|||||||
) do
|
) do
|
||||||
with %User{email: email, locale: locale} <- Users.get_user!(user_id) do
|
with %User{email: email, locale: locale} <- Users.get_user!(user_id) do
|
||||||
Gettext.put_locale(locale)
|
Gettext.put_locale(locale)
|
||||||
instance = Config.instance_name()
|
|
||||||
|
|
||||||
subject = gettext("Your participation to %{event} has been cancelled!", event: event.title)
|
subject = gettext("Your participation to %{event} has been cancelled!", event: event.title)
|
||||||
|
|
||||||
@ -50,7 +49,6 @@ defmodule Mobilizon.Web.Email.Actor do
|
|||||||
|> assign(:event, event)
|
|> assign(:event, event)
|
||||||
|> assign(:role, member_role)
|
|> assign(:role, member_role)
|
||||||
|> assign(:subject, subject)
|
|> assign(:subject, subject)
|
||||||
|> assign(:instance, instance)
|
|
||||||
|> render(:actor_suspension_participants)
|
|> render(:actor_suspension_participants)
|
||||||
|> Email.Mailer.send_email_later()
|
|> Email.Mailer.send_email_later()
|
||||||
|
|
||||||
|
@ -12,15 +12,13 @@ defmodule Mobilizon.Web.Email do
|
|||||||
|
|
||||||
@spec base_email(keyword()) :: Bamboo.Email.t()
|
@spec base_email(keyword()) :: Bamboo.Email.t()
|
||||||
def base_email(args) do
|
def base_email(args) do
|
||||||
instance = Config.instance_config()
|
|
||||||
|
|
||||||
args
|
args
|
||||||
|> new_email()
|
|> new_email()
|
||||||
|> from({Config.instance_name(), Config.instance_email_from()})
|
|> from({Config.instance_name(), Config.instance_email_from()})
|
||||||
|> put_header("Reply-To", Config.instance_email_reply_to())
|
|> put_header("Reply-To", Config.instance_email_reply_to())
|
||||||
|> maybe_put_date_header()
|
|> maybe_put_date_header()
|
||||||
|> maybe_put_message_id()
|
|> maybe_put_message_id()
|
||||||
|> assign(:instance, instance)
|
|> assign(:instance_name, Config.instance_name())
|
||||||
|> put_html_layout({EmailView, "email.html"})
|
|> put_html_layout({EmailView, "email.html"})
|
||||||
|> put_text_layout({EmailView, "email.text"})
|
|> put_text_layout({EmailView, "email.text"})
|
||||||
end
|
end
|
||||||
|
@ -92,13 +92,12 @@ defmodule Mobilizon.Web.Email.Group do
|
|||||||
}) do
|
}) do
|
||||||
with %User{email: email, locale: locale} <- Users.get_user!(user_id) do
|
with %User{email: email, locale: locale} <- Users.get_user!(user_id) do
|
||||||
Gettext.put_locale(locale)
|
Gettext.put_locale(locale)
|
||||||
instance = Config.instance_name()
|
|
||||||
|
|
||||||
subject =
|
subject =
|
||||||
gettext(
|
gettext(
|
||||||
"The group %{group} has been suspended on %{instance}",
|
"The group %{group} has been suspended on %{instance}",
|
||||||
group: group.name,
|
group: group.name,
|
||||||
instance: instance
|
instance: Config.instance_name()
|
||||||
)
|
)
|
||||||
|
|
||||||
Email.base_email(to: email, subject: subject)
|
Email.base_email(to: email, subject: subject)
|
||||||
@ -106,7 +105,6 @@ defmodule Mobilizon.Web.Email.Group do
|
|||||||
|> assign(:group, group)
|
|> assign(:group, group)
|
||||||
|> assign(:role, member_role)
|
|> assign(:role, member_role)
|
||||||
|> assign(:subject, subject)
|
|> assign(:subject, subject)
|
||||||
|> assign(:instance, instance)
|
|
||||||
|> render(:group_suspension)
|
|> render(:group_suspension)
|
||||||
|> Email.Mailer.send_email_later()
|
|> Email.Mailer.send_email_later()
|
||||||
|
|
||||||
|
@ -172,19 +172,17 @@ defmodule Mobilizon.Web.Email.User do
|
|||||||
_locale \\ "en"
|
_locale \\ "en"
|
||||||
) do
|
) do
|
||||||
Gettext.put_locale(user_locale)
|
Gettext.put_locale(user_locale)
|
||||||
instance_name = Config.instance_name()
|
|
||||||
|
|
||||||
subject =
|
subject =
|
||||||
gettext(
|
gettext(
|
||||||
"Mobilizon on %{instance}: confirm your email address",
|
"Mobilizon on %{instance}: confirm your email address",
|
||||||
instance: instance_name
|
instance: Config.instance_name()
|
||||||
)
|
)
|
||||||
|
|
||||||
Email.base_email(to: unconfirmed_email, subject: subject)
|
Email.base_email(to: unconfirmed_email, subject: subject)
|
||||||
|> assign(:locale, user_locale)
|
|> assign(:locale, user_locale)
|
||||||
|> assign(:subject, subject)
|
|> assign(:subject, subject)
|
||||||
|> assign(:token, confirmation_token)
|
|> assign(:token, confirmation_token)
|
||||||
|> assign(:instance_name, instance_name)
|
|
||||||
|> render(:email_changed_new)
|
|> render(:email_changed_new)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td bgcolor="#ffffff" align="center" valign="top" style="padding: 40px 20px 20px 20px; border-radius: 4px 4px 0px 0px; color: #3A384C; font-family: 'Roboto', Helvetica, Arial, sans-serif; font-size: 48px; font-weight: 400; line-height: 48px;">
|
<td bgcolor="#ffffff" align="center" valign="top" style="padding: 40px 20px 20px 20px; border-radius: 4px 4px 0px 0px; color: #3A384C; font-family: 'Roboto', Helvetica, Arial, sans-serif; font-size: 48px; font-weight: 400; line-height: 48px;">
|
||||||
<h1 style="font-size: 48px; font-weight: 400; margin: 0;">
|
<h1 style="font-size: 48px; font-weight: 400; margin: 0;">
|
||||||
<%= gettext "Your participation to %{event} has been cancelled!", event: (@event.title), instance: @instance %>
|
<%= gettext "Your participation to %{event} has been cancelled!", event: (@event.title), instance: @instance_name %>
|
||||||
</h1>
|
</h1>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
<%= gettext "Your participation to %{event} has been cancelled!", event: (@event.title), instance: @instance %>
|
<%= gettext "Your participation to %{event} has been cancelled!", event: (@event.title), instance: @instance_name %>
|
||||||
==
|
==
|
||||||
<%= gettext "Your instance's moderation team has decided to suspend %{actor_name} (%{actor_address}). All of their events have been removed and your participation cancelled.", group_name: @actor.name || @actor.preferred_username, actor_address: if @actor.domain, do: "@#{@actor.preferred_username}@#{@actor.domain}", else: "@#{@actor.preferred_username}" %>
|
<%= gettext "Your instance's moderation team has decided to suspend %{actor_name} (%{actor_address}). All of their events have been removed and your participation cancelled.", group_name: @actor.name || @actor.preferred_username, actor_address: if @actor.domain, do: "@#{@actor.preferred_username}@#{@actor.domain}", else: "@#{@actor.preferred_username}" %>
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td align="center" valign="top" style="padding: 40px 10px 40px 10px;">
|
<td align="center" valign="top" style="padding: 40px 10px 40px 10px;">
|
||||||
<a href="<%= Mobilizon.Web.Endpoint.url() %>" target="_blank">
|
<a href="<%= Mobilizon.Web.Endpoint.url() %>" target="_blank">
|
||||||
<img alt="<%= Mobilizon.Config.instance_name() %>" src="<%= "#{Mobilizon.Web.Endpoint.url()}/img/mobilizon_logo.png" %>" width="366" height="108" style="display: block; width: 366px; max-width: 366px; min-width: 366px; font-family: 'Roboto', Helvetica, Arial, sans-serif; color: #ffffff; font-size: 18px;" border="0">
|
<img alt="<%= @instance_name %>" src="<%= "#{Mobilizon.Web.Endpoint.url()}/img/mobilizon_logo.png" %>" width="366" height="108" style="display: block; width: 366px; max-width: 366px; min-width: 366px; font-family: 'Roboto', Helvetica, Arial, sans-serif; color: #ffffff; font-size: 18px;" border="0">
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -140,7 +140,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td bgcolor="#ECEBF2" align="center" style="padding: 30px 30px 30px 30px; color: #474467; font-family: 'Roboto', Helvetica, Arial, sans-serif; font-size: 14px; font-weight: 400; line-height: 18px;" >
|
<td bgcolor="#ECEBF2" align="center" style="padding: 30px 30px 30px 30px; color: #474467; font-family: 'Roboto', Helvetica, Arial, sans-serif; font-size: 14px; font-weight: 400; line-height: 18px;" >
|
||||||
<p style="margin: 0;">
|
<p style="margin: 0;">
|
||||||
<%= gettext("<b>%{instance}</b> is powered by Mobilizon.", instance: @instance[:name]) |> raw %><br />
|
<%= gettext("<b>%{instance}</b> is powered by Mobilizon.", instance: @instance_name) |> raw %><br />
|
||||||
<a href="https://joinmobilizon.org"><%= gettext "Learn more about Mobilizon here!" %></a>
|
<a href="https://joinmobilizon.org"><%= gettext "Learn more about Mobilizon here!" %></a>
|
||||||
</p>
|
</p>
|
||||||
</td>
|
</td>
|
||||||
|
@ -8,4 +8,4 @@
|
|||||||
<%= gettext "Need help? Is something not working as expected?" %>
|
<%= gettext "Need help? Is something not working as expected?" %>
|
||||||
<%= gettext "Ask the community on Framacolibri" %> https://framacolibri.org/c/mobilizon/39
|
<%= gettext "Ask the community on Framacolibri" %> https://framacolibri.org/c/mobilizon/39
|
||||||
|
|
||||||
<%= gettext "%{instance} is powered by Mobilizon.", instance: @instance[:name] %> <%= gettext "Learn more about Mobilizon here!" %> https://joinmobilizon.org
|
<%= gettext "%{instance} is powered by Mobilizon.", instance: @instance_name %> <%= gettext "Learn more about Mobilizon here!" %> https://joinmobilizon.org
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td bgcolor="#ffffff" align="left" style="padding: 20px 30px 0px 30px; color: #474467; font-family: 'Roboto', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;" >
|
<td bgcolor="#ffffff" align="left" style="padding: 20px 30px 0px 30px; color: #474467; font-family: 'Roboto', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;" >
|
||||||
<p style="margin: 0;">
|
<p style="margin: 0;">
|
||||||
<%= gettext("The email address for your account on <b>%{host}</b> is being changed to:", host: @instance[:name]) |> raw %>
|
<%= gettext("The email address for your account on <b>%{host}</b> is being changed to:", host: @instance_name) |> raw %>
|
||||||
</p>
|
</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -59,7 +59,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td bgcolor="#ffffff" align="left" style="padding: 20px 30px 0px 30px; color: #474467; font-family: 'Roboto', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;" >
|
<td bgcolor="#ffffff" align="left" style="padding: 20px 30px 0px 30px; color: #474467; font-family: 'Roboto', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;" >
|
||||||
<p>
|
<p>
|
||||||
<%= gettext("If you did not trigger this change yourself, it is likely that someone has gained access to your %{host} account. Please log in and change your password immediately. If you cannot login, contact the admin on %{host}.", host: @instance[:name]) %>
|
<%= gettext("If you did not trigger this change yourself, it is likely that someone has gained access to your %{host} account. Please log in and change your password immediately. If you cannot login, contact the admin on %{host}.", host: @instance_name) %>
|
||||||
</p>
|
</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<%= gettext "New email confirmation" %>
|
<%= gettext "New email confirmation" %>
|
||||||
==
|
==
|
||||||
<%= gettext "Hi there! Just a quick note to confirm that the email address linked to your account on %{host} has been changed from this one to:", host: @instance[:name] %>
|
<%= gettext "Hi there! Just a quick note to confirm that the email address linked to your account on %{host} has been changed from this one to:", host: @instance_name %>
|
||||||
<%= @new_email %>
|
<%= @new_email %>
|
||||||
<%= gettext "If you did not trigger this change yourself, it is likely that someone has gained access to your %{host} account. Please log in and change your password immediately. If you cannot login, contact the admin on %{host}.", host: @instance[:name] %>
|
<%= gettext "If you did not trigger this change yourself, it is likely that someone has gained access to your %{host} account. Please log in and change your password immediately. If you cannot login, contact the admin on %{host}.", host: @instance_name %>
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td bgcolor="#ffffff" align="center" valign="top" style="padding: 40px 20px 20px 20px; border-radius: 4px 4px 0px 0px; color: #3A384C; font-family: 'Roboto', Helvetica, Arial, sans-serif; font-size: 48px; font-weight: 400; line-height: 48px;">
|
<td bgcolor="#ffffff" align="center" valign="top" style="padding: 40px 20px 20px 20px; border-radius: 4px 4px 0px 0px; color: #3A384C; font-family: 'Roboto', Helvetica, Arial, sans-serif; font-size: 48px; font-weight: 400; line-height: 48px;">
|
||||||
<h1 style="font-size: 48px; font-weight: 400; margin: 0;">
|
<h1 style="font-size: 48px; font-weight: 400; margin: 0;">
|
||||||
<%= gettext "The group %{group} has been suspended on %{instance}!", group: (@group.name || @group.preferred_username), instance: @instance %>
|
<%= gettext "The group %{group} has been suspended on %{instance}!", group: (@group.name || @group.preferred_username), instance: @instance_name %>
|
||||||
</h1>
|
</h1>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<%= gettext "The group %{group} has been suspended on %{instance}!", group: (@group.name || @group.preferred_username), instance: @instance %>
|
<%= gettext "The group %{group} has been suspended on %{instance}!", group: (@group.name || @group.preferred_username), instance: @instance_name %>
|
||||||
==
|
==
|
||||||
<%= gettext "Your instance's moderation team has decided to suspend %{group_name} (%{group_address}). You are no longer a member of this group.", group_name: @group.name, group_address: if @group.domain, do: "@#{@group.preferred_username}@#{@group.domain}", else: "@#{@group.preferred_username}" %>
|
<%= gettext "Your instance's moderation team has decided to suspend %{group_name} (%{group_address}). You are no longer a member of this group.", group_name: @group.name, group_address: if @group.domain, do: "@#{@group.preferred_username}@#{@group.domain}", else: "@#{@group.preferred_username}" %>
|
||||||
<%= if is_nil(@group.domain) do %>
|
<%= if is_nil(@group.domain) do %>
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td bgcolor="#ffffff" align="left" style="padding: 20px 30px 0px 30px; color: #474467; font-family: 'Roboto', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;" >
|
<td bgcolor="#ffffff" align="left" style="padding: 20px 30px 0px 30px; color: #474467; font-family: 'Roboto', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;" >
|
||||||
<p style="margin: 0;">
|
<p style="margin: 0;">
|
||||||
<%= gettext("You requested a new password for your account on <b>%{instance}</b>.", instance: @instance[:name]) |> raw %>
|
<%= gettext("You requested a new password for your account on <b>%{instance}</b>.", instance: @instance_name) |> raw %>
|
||||||
</p>
|
</p>
|
||||||
<p style="margin: 0">
|
<p style="margin: 0">
|
||||||
<%= gettext "Resetting your password is easy. Just press the button below and follow the instructions. We'll have you up and running in no time." %>
|
<%= gettext "Resetting your password is easy. Just press the button below and follow the instructions. We'll have you up and running in no time." %>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
==
|
==
|
||||||
|
|
||||||
<%= gettext "You requested a new password for your account on %{instance}.", instance: @instance[:name] %>
|
<%= gettext "You requested a new password for your account on %{instance}.", instance: @instance_name %>
|
||||||
|
|
||||||
<%= gettext "Resetting your password is easy. Just click the link below and follow the instructions. We'll have you up and running in no time." %>
|
<%= gettext "Resetting your password is easy. Just click the link below and follow the instructions. We'll have you up and running in no time." %>
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td bgcolor="#ffffff" align="left" style="padding: 20px 30px 0px 30px; color: #474467; font-family: 'Roboto', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;" >
|
<td bgcolor="#ffffff" align="left" style="padding: 20px 30px 0px 30px; color: #474467; font-family: 'Roboto', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;" >
|
||||||
<p style="margin: 0;">
|
<p style="margin: 0;">
|
||||||
<%= gettext("You created an account on <b>%{host}</b> with this email address. You are one click away from activating it.", host: @instance[:name]) |> raw %>
|
<%= gettext("You created an account on <b>%{host}</b> with this email address. You are one click away from activating it.", host: @instance_name) |> raw %>
|
||||||
</p>
|
</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
|
|
||||||
==
|
==
|
||||||
|
|
||||||
<%= gettext "You created an account on %{host} with this email address. You are one click away from activating it. If this wasn't you, please ignore this email.", host: @instance[:name] %>
|
<%= gettext "You created an account on %{host} with this email address. You are one click away from activating it. If this wasn't you, please ignore this email.", host: @instance_name %>
|
||||||
|
|
||||||
<%= Mobilizon.Web.Endpoint.url() <> "/validate/#{@token}" %>
|
<%= Mobilizon.Web.Endpoint.url() <> "/validate/#{@token}" %>
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td bgcolor="#ffffff" align="center" valign="top" style="padding: 40px 20px 20px 20px; border-radius: 4px 4px 0px 0px; color: #3A384C; font-family: 'Roboto', Helvetica, Arial, sans-serif; font-size: 48px; font-weight: 400; line-height: 48px;">
|
<td bgcolor="#ffffff" align="center" valign="top" style="padding: 40px 20px 20px 20px; border-radius: 4px 4px 0px 0px; color: #3A384C; font-family: 'Roboto', Helvetica, Arial, sans-serif; font-size: 48px; font-weight: 400; line-height: 48px;">
|
||||||
<h1 style="font-size: 48px; font-weight: 400; margin: 0;">
|
<h1 style="font-size: 48px; font-weight: 400; margin: 0;">
|
||||||
<%= gettext("New report on <b>%{instance}</b>", instance: @instance[:name]) |> raw %>
|
<%= gettext("New report on <b>%{instance}</b>", instance: @instance_name) |> raw %>
|
||||||
</h1>
|
</h1>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<%= gettext "New report from %{reporter} on %{instance}", reporter: Mobilizon.Actors.Actor.display_name_and_username(@report.reporter), instance: @instance[:name] %>
|
<%= gettext "New report from %{reporter} on %{instance}", reporter: Mobilizon.Actors.Actor.display_name_and_username(@report.reporter), instance: @instance_name %>
|
||||||
--
|
--
|
||||||
<%= if @report.reported do %>
|
<%= if @report.reported do %>
|
||||||
<%= if @report.reported.type == :Group do %>
|
<%= if @report.reported.type == :Group do %>
|
||||||
|
Loading…
Reference in New Issue
Block a user