Skip to content

Commit

Permalink
Disable automatic hyperlink in email template
Browse files Browse the repository at this point in the history
  • Loading branch information
ikus060 committed Dec 22, 2022
1 parent b0c1422 commit 6afaae5
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 28 deletions.
4 changes: 2 additions & 2 deletions rdiffweb/core/notification.py
Expand Up @@ -73,7 +73,7 @@ def access_token_added(self, userobj, name):

# Send a mail notification
body = self.app.templates.compile_template(
"access_token_added.html", **{"header_name": self.app.cfg.header_name, 'user': userobj, 'name': name}
"email_access_token_added.html", **{"header_name": self.app.cfg.header_name, 'user': userobj, 'name': name}
)
self.bus.publish('queue_mail', to=userobj.email, subject=_("A new access token has been created"), message=body)

Expand Down Expand Up @@ -118,7 +118,7 @@ def user_password_changed(self, userobj):

# If the email attributes was changed, send a mail notification.
body = self.app.templates.compile_template(
"password_changed.html", **{"header_name": self.app.cfg.header_name, 'user': userobj}
"email_password_changed.html", **{"header_name": self.app.cfg.header_name, 'user': userobj}
)
self.bus.publish('queue_mail', to=userobj.email, subject=_("Password changed"), message=body)

Expand Down
10 changes: 5 additions & 5 deletions rdiffweb/core/tests/test_notification.py
Expand Up @@ -64,7 +64,7 @@ def test_notification_job(self):
self.listener.queue_email.assert_called_once_with(
to='test@test.com',
subject='Notification',
message="<html>\n <head></head>\n <body>\n Hey admin,\n <p>\n You are receiving this email to notify you about your backups. The\n following repositories are inactive for some time. We invite you to have a look\n at your last backup schedule.\n </p>\n <ul>\n <li>testcases</li>\n </ul>\n <p>\n If you don't want to be notify about this. You need to review your\n user preferences.\n </p>\n </body>\n</html>",
message="<html>\n <head></head>\n <body>\n <p>\n <a>Hey admin,</a>\n </p>\n <p>\n You are receiving this email to notify you about your backups. The\n following repositories are inactive for some time. We invite you to have a look\n at your last backup schedule.\n </p>\n <ul>\n \n <li>\n <a>testcases</a>\n </li>\n \n </ul>\n <p>If you don't want to be notify about this. You need to review your user preferences.</p>\n </body>\n</html>",
)

def test_notification_job_undefined_last_backup_date(self):
Expand All @@ -85,7 +85,7 @@ def test_notification_job_undefined_last_backup_date(self):
self.listener.queue_email.assert_called_once_with(
to='test@test.com',
subject='Notification',
message="<html>\n <head></head>\n <body>\n Hey admin,\n <p>\n You are receiving this email to notify you about your backups. The\n following repositories are inactive for some time. We invite you to have a look\n at your last backup schedule.\n </p>\n <ul>\n <li>broker-repo</li>\n </ul>\n <p>\n If you don't want to be notify about this. You need to review your\n user preferences.\n </p>\n </body>\n</html>",
message="<html>\n <head></head>\n <body>\n <p>\n <a>Hey admin,</a>\n </p>\n <p>\n You are receiving this email to notify you about your backups. The\n following repositories are inactive for some time. We invite you to have a look\n at your last backup schedule.\n </p>\n <ul>\n \n <li>\n <a>broker-repo</a>\n </li>\n \n </ul>\n <p>If you don't want to be notify about this. You need to review your user preferences.</p>\n </body>\n</html>",
)

def test_notification_job_without_notification(self):
Expand Down Expand Up @@ -135,7 +135,7 @@ def test_email_changed(self):
self.listener.queue_email.assert_called_once_with(
to='original_email@test.com',
subject='Email address changed',
message='<html>\n <head></head>\n <body>\n Hey admin,\n <p>You recently changed the email address associated with your Rdiffweb account.</p>\n <p>\n If you did not make this change and believe your account has been compromised, please contact your administrator.\n </p>\n </body>\n</html>',
message='<html>\n <head></head>\n <body>\n <p>\n <a>Hey admin,</a>\n </p>\n <p>\n <a>You recently changed the email address associated with your Rdiffweb account.</a>\n </p>\n <p>\n If you did not make this change and believe your account has been compromised, please contact your administrator.\n </p>\n </body>\n</html>',
)

def test_email_updated_with_same_value(self):
Expand Down Expand Up @@ -167,7 +167,7 @@ def test_password_change_notification(self):
self.listener.queue_email.assert_called_once_with(
to='password_change@test.com',
subject='Password changed',
message='<html>\n <head></head>\n <body>\n Hey admin,\n <p>You recently changed the password associated with your Rdiffweb account.</p>\n <p>\n If you did not make this change and believe your account has been compromised, please contact your administrator.\n </p>\n </body>\n</html>',
message='<html>\n <head></head>\n <body>\n <p>\n <a>Hey admin,</a>\n </p>\n <p>You recently changed the password associated with your Rdiffweb account.</p>\n <p>\n If you did not make this change and believe your account has been compromised, please contact your administrator.\n </p>\n </body>\n</html>',
)

def test_password_change_with_same_value(self):
Expand All @@ -186,5 +186,5 @@ def test_password_change_with_same_value(self):
self.listener.queue_email.assert_called_once_with(
to='password_change@test.com',
subject='Password changed',
message='<html>\n <head></head>\n <body>\n Hey admin,\n <p>You recently changed the password associated with your Rdiffweb account.</p>\n <p>\n If you did not make this change and believe your account has been compromised, please contact your administrator.\n </p>\n </body>\n</html>',
message='<html>\n <head></head>\n <body>\n <p>\n <a>Hey admin,</a>\n </p>\n <p>You recently changed the password associated with your Rdiffweb account.</p>\n <p>\n If you did not make this change and believe your account has been compromised, please contact your administrator.\n </p>\n </body>\n</html>',
)
10 changes: 0 additions & 10 deletions rdiffweb/templates/access_token_added.html

This file was deleted.

14 changes: 14 additions & 0 deletions rdiffweb/templates/email_access_token_added.html
@@ -0,0 +1,14 @@
<html>
<head></head>
<body>
<p>
<a>{% trans username=(user.fullname or user.username) %}Hey {{ username }},{% endtrans %}</a>
</p>
<p>
<a>{% trans %}A new access token, named "{{ name }}", has been created.{% endtrans %}</a>
</p>
<p>
{% trans %}If you did not make this change and believe your account has been compromised, please contact your administrator.{% endtrans %}
</p>
</body>
</html>
8 changes: 6 additions & 2 deletions rdiffweb/templates/email_changed.html
@@ -1,8 +1,12 @@
<html>
<head></head>
<body>
{% trans username=(user.fullname or user.username) %}Hey {{ username }},{% endtrans %}
<p>{% trans %}You recently changed the email address associated with your {{ header_name }} account.{% endtrans %}</p>
<p>
<a>{% trans username=(user.fullname or user.username) %}Hey {{ username }},{% endtrans %}</a>
</p>
<p>
<a>{% trans %}You recently changed the email address associated with your {{ header_name }} account.{% endtrans %}</a>
</p>
<p>
{% trans %}If you did not make this change and believe your account has been compromised, please contact your administrator.{% endtrans %}
</p>
Expand Down
4 changes: 3 additions & 1 deletion rdiffweb/templates/email_mfa.html
@@ -1,7 +1,9 @@
<html>
<head></head>
<body>
{% trans username=(user.fullname or user.username) %}Hey {{ username }},{% endtrans %}
<p>
<a>{% trans username=(user.fullname or user.username) %}Hey {{ username }},{% endtrans %}</a>
</p>
<p>
{% if user.mfa %}
{% trans %}Your {{ header_name }} Account is now protected with Two-Factor Authentication. When you sign in on a new or untrusted device, you'll need your second factor to verify your identity.{% endtrans %}
Expand Down
15 changes: 9 additions & 6 deletions rdiffweb/templates/email_notification.html
@@ -1,18 +1,21 @@
<html>
<head></head>
<body>
{% trans username=(user.fullname or user.username) %}Hey {{ username }},{% endtrans %}
<p>
<a>{% trans username=(user.fullname or user.username) %}Hey {{ username }},{% endtrans %}</a>
</p>
<p>
{% trans %}You are receiving this email to notify you about your backups. The
following repositories are inactive for some time. We invite you to have a look
at your last backup schedule.{% endtrans %}
</p>
<ul>
{% for r in repos %}<li>{{ r.display_name }}</li>{% endfor %}
{% for r in repos %}
<li>
<a>{{ r.display_name }}</a>
</li>
{% endfor %}
</ul>
<p>
{% trans %}If you don't want to be notify about this. You need to review your
user preferences.{% endtrans %}
</p>
<p>{% trans %}If you don't want to be notify about this. You need to review your user preferences.{% endtrans %}</p>
</body>
</html>
@@ -1,7 +1,9 @@
<html>
<head></head>
<body>
{% trans username=user.username %}Hey {{ username }},{% endtrans %}
<p>
<a>{% trans username=(user.fullname or user.username) %}Hey {{ username }},{% endtrans %}</a>
</p>
<p>{% trans %}You recently changed the password associated with your {{ header_name }} account.{% endtrans %}</p>
<p>
{% trans %}If you did not make this change and believe your account has been compromised, please contact your administrator.{% endtrans %}
Expand Down
4 changes: 3 additions & 1 deletion rdiffweb/templates/email_verification_code.html
@@ -1,7 +1,9 @@
<html>
<head></head>
<body>
{% trans username=(user.fullname or user.username) %}Hey {{ username }},{% endtrans %}
<p>
<a>{% trans username=(user.fullname or user.username) %}Hey {{ username }},{% endtrans %}</a>
</p>
<p>
{% trans %}To help us make sure it's really you, here's the verification code you'll need to log in:{% endtrans %}
</p>
Expand Down

0 comments on commit 6afaae5

Please sign in to comment.