update email template

This commit is contained in:
Son NK 2021-06-03 11:34:53 +02:00
parent 85c35224a7
commit 88af5cb6db
4 changed files with 59 additions and 51 deletions

View File

@ -915,7 +915,7 @@ def notify_hibp():
user.email, user.email,
f"You were in a data breach", f"You were in a data breach",
render( render(
"transactional/hibp-new-breaches.txt", "transactional/hibp-new-breaches.txt.jinja2",
user=user, user=user,
breached_aliases=new_breaches, breached_aliases=new_breaches,
), ),

View File

@ -1,30 +1,44 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block content %} {% block content %}
{{ render_text("Hi") }} {% call text() %}
<h1>
{{ breached_aliases|count }} of your aliases are found in data breaches.
</h1>
{% endcall %}
{%- for alias in breached_aliases %} <ol>
{%- if loop.index == 11 and loop.length > 10 %} {%- for alias in breached_aliases[:10] %}
<li>{% call text() %}
<b>{{ alias.email }}</b> was found in {{ alias.hibp_breaches_not_notified_user|count }} data breaches. <br>
<ul>
{% set breaches = alias.hibp_breaches_not_notified_user|sort(attribute='date', reverse=True) %}
{%- for breach in breaches[:4] %}
<li>
<b>{{ breach.name }}</b> ({{ breach.date.format('YYYY-MM-DD') }}).
{{ breach.description }}
Breached data includes {{ breach.data_classes|join(', ', attribute='attribute') }}.
</li>
{%- endfor %}
</ul>
{% if breaches|length > 4 %}
And {{ breaches|length - 4 }} more data breaches...
{% endif %}
{% endcall %}</li>
{%- endfor %}
</ol>
{% if breached_aliases|length > 10 %}
{% call text() %}
And {{ breached_aliases|length - 10 }} more aliases... And {{ breached_aliases|length - 10 }} more aliases...
{%- elif loop.index > 11 %} {% endcall %}
{%- else %} {% endif %}
{{ render_text("Your alias " + alias.email + " was found in one or more data breaches:") }}
{%- for breach in alias.hibp_breaches_not_notified_user|sort(attribute='date', reverse=True) %} {{ render_text("For more information, please check <a href='https://haveibeenpwned.com/'>HaveIBeenPwned.com</a>.") }}
{%- if loop.index == 4 and loop.length > 4 %}
{{ render_text("And " + ((alias.hibp_breaches_not_notified_user|length) - 3)|string + " more data breaches...") }}
{%- elif loop.index > 4 %}
{%- else %}
{{ render_text(breach.name + " (" + breach.date.format('YYYY-MM-DD') + ")") }}
{{ render_text(breach.description) }}
{{ render_text("Breached data: " + breach.data_classes|join(', ', attribute='attribute')) }}
{%- endif %}
{%- endfor %}
{%- endif %}
{%- endfor %}
{{ render_text("For more information, check <a href='https://haveibeenpwned.com/'>HaveIBeenPwned.com</a>.") }}
{{ render_text('Best, <br />SimpleLogin Team.') }} {{ render_text('Best, <br />SimpleLogin Team.') }}
{% endblock %} {% endblock %}

View File

@ -1,30 +0,0 @@
Hi
{%- for alias in breached_aliases %}
{%- if loop.index == 11 and loop.length > 10 %}
And {{ breached_aliases|length - 10 }} more aliases...
{%- elif loop.index > 11 %}
{%- else %}
Your alias {{ alias.email }} was found in one or more data breaches:
{%- for breach in alias.hibp_breaches_not_notified_user|sort(attribute='date', reverse=True) %}
{%- if loop.index == 4 and loop.length > 4 %}
And {{ (alias.hibp_breaches_not_notified_user|length) - 3 }} more data breaches...
{%- elif loop.index > 4 %}
{%- else %}
{{ breach.name }} ({{ breach.date.format('YYYY-MM-DD') }})
{{ breach.description|striptags }}
Breached data: {{ breach.data_classes|join(', ', attribute='attribute') }}
{%- endif %}
{%- endfor %}
{%- endif %}
{%- endfor %}
For more information, check https://haveibeenpwned.com/.
Best,
SimpleLogin Team.

View File

@ -0,0 +1,24 @@
{{ breached_aliases|count }} of your aliases are found in data breaches.
{% for alias in breached_aliases[:10] %}
{{ loop.index }} ) {{ alias.email }} was found in {{ alias.hibp_breaches_not_notified_user|count }} data breaches.
{%- set breaches = alias.hibp_breaches_not_notified_user|sort(attribute='date', reverse=True) %}
{% for breach in breaches[:4] %}
- {{ breach.name }} ({{ breach.date.format('YYYY-MM-DD') }}). Breached data includes {{ breach.data_classes|join(', ', attribute='attribute') }}.
{%- endfor %}
{%- if breaches|length > 4 %}
And {{ breaches|length - 4 }} more data breaches...
{% endif %}
{% endfor %}
{%- if breached_aliases|length > 10 %}
And {{ breached_aliases|length - 10 }} more aliases...
{%- endif %}
For more information, please check https://haveibeenpwned.com/.
Best,
SimpleLogin Team.