make emails more efficient
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
f00dc50215
commit
1276635a3e
@ -29,33 +29,28 @@ defmodule Memex.Email do
|
|||||||
def generate_email("welcome", user, %{"url" => url}) do
|
def generate_email("welcome", user, %{"url" => url}) do
|
||||||
user
|
user
|
||||||
|> base_email(dgettext("emails", "confirm your memEx account"))
|
|> base_email(dgettext("emails", "confirm your memEx account"))
|
||||||
|> html_email(:confirm_email_html, %{user: user, url: url})
|
|> render_body(:confirm_email, %{user: user, url: url})
|
||||||
|> text_email(:confirm_email_text, %{user: user, url: url})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_email("reset_password", user, %{"url" => url}) do
|
def generate_email("reset_password", user, %{"url" => url}) do
|
||||||
user
|
user
|
||||||
|> base_email(dgettext("emails", "reset your memEx password"))
|
|> base_email(dgettext("emails", "reset your memEx password"))
|
||||||
|> html_email(:reset_password_html, %{user: user, url: url})
|
|> render_body(:reset_password, %{user: user, url: url})
|
||||||
|> text_email(:reset_password_text, %{user: user, url: url})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_email("update_email", user, %{"url" => url}) do
|
def generate_email("update_email", user, %{"url" => url}) do
|
||||||
user
|
user
|
||||||
|> base_email(dgettext("emails", "update your memEx email"))
|
|> base_email(dgettext("emails", "update your memEx email"))
|
||||||
|> html_email(:update_email_html, %{user: user, url: url})
|
|> render_body(:update_email, %{user: user, url: url})
|
||||||
|> text_email(:update_email_text, %{user: user, url: url})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
defp html_email(email, atom, assigns) do
|
defp render_body(email, template, assigns) do
|
||||||
heex = apply(EmailHTML, atom, [assigns])
|
html_heex = apply(EmailHTML, String.to_existing_atom("#{template}_html"), [assigns])
|
||||||
html = render_to_string(Layouts, "email_html", "html", email: email, inner_content: heex)
|
html = render_to_string(Layouts, "email_html", "html", email: email, inner_content: html_heex)
|
||||||
email |> html_body(html)
|
|
||||||
end
|
|
||||||
|
|
||||||
defp text_email(email, atom, assigns) do
|
text_heex = apply(EmailHTML, String.to_existing_atom("#{template}_text"), [assigns])
|
||||||
heex = apply(EmailHTML, atom, [assigns])
|
text = render_to_string(Layouts, "email_text", "text", email: email, inner_content: text_heex)
|
||||||
text = render_to_string(Layouts, "email_text", "text", email: email, inner_content: heex)
|
|
||||||
email |> text_body(text)
|
email |> html_body(html) |> text_body(text)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -71,7 +71,7 @@ msgstr ""
|
|||||||
msgid "confirm your memEx account"
|
msgid "confirm your memEx account"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/memex/accounts/email.ex:38
|
#: lib/memex/accounts/email.ex:37
|
||||||
#, elixir-autogen, elixir-format, fuzzy
|
#, elixir-autogen, elixir-format, fuzzy
|
||||||
msgid "reset your memEx password"
|
msgid "reset your memEx password"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@ -86,7 +86,7 @@ msgstr ""
|
|||||||
msgid "this email was sent from memEx at %{url}"
|
msgid "this email was sent from memEx at %{url}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/memex/accounts/email.ex:45
|
#: lib/memex/accounts/email.ex:43
|
||||||
#, elixir-autogen, elixir-format, fuzzy
|
#, elixir-autogen, elixir-format, fuzzy
|
||||||
msgid "update your memEx email"
|
msgid "update your memEx email"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
@ -71,7 +71,7 @@ msgstr ""
|
|||||||
msgid "confirm your memEx account"
|
msgid "confirm your memEx account"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/memex/accounts/email.ex:38
|
#: lib/memex/accounts/email.ex:37
|
||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
msgid "reset your memEx password"
|
msgid "reset your memEx password"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@ -86,7 +86,7 @@ msgstr ""
|
|||||||
msgid "this email was sent from memEx at %{url}"
|
msgid "this email was sent from memEx at %{url}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/memex/accounts/email.ex:45
|
#: lib/memex/accounts/email.ex:43
|
||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
msgid "update your memEx email"
|
msgid "update your memEx email"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
@ -72,7 +72,7 @@ msgstr ""
|
|||||||
msgid "confirm your memEx account"
|
msgid "confirm your memEx account"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/memex/accounts/email.ex:38
|
#: lib/memex/accounts/email.ex:37
|
||||||
#, elixir-autogen, elixir-format, fuzzy
|
#, elixir-autogen, elixir-format, fuzzy
|
||||||
msgid "reset your memEx password"
|
msgid "reset your memEx password"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@ -87,7 +87,7 @@ msgstr ""
|
|||||||
msgid "this email was sent from memEx at %{url}"
|
msgid "this email was sent from memEx at %{url}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/memex/accounts/email.ex:45
|
#: lib/memex/accounts/email.ex:43
|
||||||
#, elixir-autogen, elixir-format, fuzzy
|
#, elixir-autogen, elixir-format, fuzzy
|
||||||
msgid "update your memEx email"
|
msgid "update your memEx email"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
Loading…
Reference in New Issue
Block a user