diff --git a/app/email_utils.py b/app/email_utils.py index 4e917b46..3934d51b 100644 --- a/app/email_utils.py +++ b/app/email_utils.py @@ -20,7 +20,7 @@ from app.config import ( from app.log import LOG -def _render(template_name, **kwargs) -> str: +def render(template_name, **kwargs) -> str: templates_dir = os.path.join(ROOT_DIR, "templates", "emails") env = Environment(loader=FileSystemLoader(templates_dir)) @@ -33,8 +33,8 @@ def send_welcome_email(user): send_email( user.email, f"Welcome to SimpleLogin {user.name}", - _render("com/welcome.txt", name=user.name, user=user), - _render("com/welcome.html", name=user.name, user=user), + render("com/welcome.txt", name=user.name, user=user), + render("com/welcome.html", name=user.name, user=user), ) @@ -42,8 +42,8 @@ def send_trial_end_soon_email(user): send_email( user.email, f"Your trial will end soon {user.name}", - _render("transactional/trial-end.txt", name=user.name, user=user), - _render("transactional/trial-end.html", name=user.name, user=user), + render("transactional/trial-end.txt", name=user.name, user=user), + render("transactional/trial-end.html", name=user.name, user=user), ) @@ -51,13 +51,13 @@ def send_activation_email(email, name, activation_link): send_email( email, f"Just one more step to join SimpleLogin {name}", - _render( + render( "transactional/activation.txt", name=name, activation_link=activation_link, email=email, ), - _render( + render( "transactional/activation.html", name=name, activation_link=activation_link, @@ -70,12 +70,12 @@ def send_reset_password_email(email, name, reset_password_link): send_email( email, f"Reset your password on SimpleLogin", - _render( + render( "transactional/reset-password.txt", name=name, reset_password_link=reset_password_link, ), - _render( + render( "transactional/reset-password.html", name=name, reset_password_link=reset_password_link, @@ -87,14 +87,14 @@ def send_change_email(new_email, current_email, name, link): send_email( new_email, f"Confirm email update on SimpleLogin", - _render( + render( "transactional/change-email.txt", name=name, link=link, new_email=new_email, current_email=current_email, ), - _render( + render( "transactional/change-email.html", name=name, link=link, @@ -108,8 +108,8 @@ def send_new_app_email(email, name): send_email( email, f"Any question/feedback for SimpleLogin {name}?", - _render("com/new-app.txt", name=name), - _render("com/new-app.html", name=name), + render("com/new-app.txt", name=name), + render("com/new-app.html", name=name), ) @@ -117,8 +117,8 @@ def send_test_email_alias(email, name): send_email( email, f"This email is sent to {email}", - _render("transactional/test-email.txt", name=name, alias=email), - _render("transactional/test-email.html", name=name, alias=email), + render("transactional/test-email.txt", name=name, alias=email), + render("transactional/test-email.html", name=name, alias=email), ) @@ -129,13 +129,13 @@ def send_cannot_create_directory_alias(user, alias, directory): send_email( user.email, f"Alias {alias} cannot be created", - _render( + render( "transactional/cannot-create-alias-directory.txt", name=user.name, alias=alias, directory=directory, ), - _render( + render( "transactional/cannot-create-alias-directory.html", name=user.name, alias=alias, @@ -151,13 +151,13 @@ def send_cannot_create_domain_alias(user, alias, domain): send_email( user.email, f"Alias {alias} cannot be created", - _render( + render( "transactional/cannot-create-alias-domain.txt", name=user.name, alias=alias, domain=domain, ), - _render( + render( "transactional/cannot-create-alias-domain.html", name=user.name, alias=alias, @@ -174,14 +174,14 @@ def send_reply_alias_must_use_personal_email(user, alias, sender): send_email( user.email, f"Reply from your alias {alias} only works with your personal email", - _render( + render( "transactional/reply-must-use-personal-email.txt", name=user.name, alias=alias, sender=sender, user_email=user.email, ), - _render( + render( "transactional/reply-must-use-personal-email.html", name=user.name, alias=alias,