Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Handle language on registration email #219

Merged
merged 6 commits into from
May 4, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 8 additions & 35 deletions apps/lenra/lib/lenra/services/email_services.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,55 +10,28 @@ defmodule Lenra.EmailService do
new_email()
|> to(email_address)
|> from("no-reply@lenra.io")
|> SendGridHelper.with_template("d-bd160809d9a04b07ac6925a823f8f61c")
|> SendGridHelper.add_dynamic_field("subject", "Bienvenue !")
|> SendGridHelper.add_dynamic_field(
"body_hello",
"Bonjour " <> email_address <> ",<br />Merci pour votre inscription! Vous rejoignez une communauté incroyable"
)
|> SendGridHelper.add_dynamic_field("code", code)
|> SendGridHelper.add_dynamic_field(
"body_help",
"Ce code vous permet de valider votre inscription.<br />Si vous rencontrez un problème contactez-nous à l'adresse mail suivante : <a href=\"mailto:contact@lenra.io?subject=&amp;body=\">contact@lenra.io</a>"
)
|> SendGridHelper.with_template("d-311a3dc52f6d44c2b613e3367e7ba82b")
|> SendGridHelper.add_dynamic_field("token", code)
end

@spec create_recovery_email(String.t(), String.t()) :: Bamboo.Email.t()
def create_recovery_email(email_address, code) do
# base template ID : d-4f7744c575434313a767f1b11cc389c1
new_email()
|> to(email_address)
|> from("no-reply@lenra.io")
|> SendGridHelper.with_template("d-bd160809d9a04b07ac6925a823f8f61c")
|> SendGridHelper.add_dynamic_field("subject", "Votre code de vérification")
|> SendGridHelper.add_dynamic_field(
"body_hello",
"Bonjour " <> email_address <> ",<br />Modifiez votre mot de passe à l'aide du code suivant"
)
|> SendGridHelper.add_dynamic_field("code", code)
|> SendGridHelper.add_dynamic_field(
"body_help",
"Ce code vous permet de modifier votre mot de passe.<br />Si vous rencontrez un problème contactez-nous à l'adresse mail suivante : <a href=\"mailto:contact@lenra.io?subject=&amp;body=\">contact@lenra.io</a>"
)
|> SendGridHelper.with_template("d-4f7744c575434313a767f1b11cc389c1")
|> SendGridHelper.add_dynamic_field("token", code)
end

@spec create_invitation_email(String.t(), String.t(), String.t()) :: Bamboo.Email.t()
def create_invitation_email(email_address, application_name, app_link) do
# base template ID : d-61866b0c62b347d3880155d680036f65
new_email()
|> to(email_address)
|> from("no-reply@lenra.io")
|> SendGridHelper.with_template("d-1d702d4b28b94b2da1bb713ac091f9fa")
|> SendGridHelper.add_dynamic_field("subject", "Invitation à rejoindre une application sur Lenra")
|> SendGridHelper.add_dynamic_field(
"body_hello",
"Bonjour,<br />Vous avez été invité à rejoindre " <>
application_name <>
" sur Lenra.<br />Pour y accéder, cliquez sur le lien suivant:"
)
|> SendGridHelper.with_template("d-61866b0c62b347d3880155d680036f65")
|> SendGridHelper.add_dynamic_field("application_name", application_name)
|> SendGridHelper.add_dynamic_field("link", app_link)
ClementGld marked this conversation as resolved.
Show resolved Hide resolved
|> SendGridHelper.add_dynamic_field(
"body_help",
"Si vous rencontrez un problème contactez-nous à l'adresse mail suivante : <a href=\"mailto:contact@lenra.io?subject=&amp;body=\">contact@lenra.io</a>"
)
|> SendGridHelper.add_dynamic_field("goodbye", "A bientôt !")
end
end
2 changes: 1 addition & 1 deletion apps/lenra/test/lenra/services/user_services_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ defmodule UserServicesTest do
assert String.length(registration_code.code) == 8
end

# Uncomment when the email service is enabled
# Uncomment when the email service is enables
jonas-martinez marked this conversation as resolved.
Show resolved Hide resolved
# test "send email after registration" do
# {:ok, %{inserted_user: user, inserted_registration_code: registration_code}} = register_john_doe()

Expand Down