diff --git a/h/emails/mention_notification.py b/h/emails/mention_notification.py index 5c31c484bfc..08d890365f2 100644 --- a/h/emails/mention_notification.py +++ b/h/emails/mention_notification.py @@ -2,14 +2,15 @@ from pyramid.request import Request from h import links -from h.emails.util import get_user_url from h.notification.mention import MentionNotification from h.services.email import EmailTag def generate(request: Request, notification: MentionNotification): + selectors = notification.annotation.target[0].get("selector", []) + quote = next((s for s in selectors if s.get("type") == "TextQuoteSelector"), None) context = { - "user_url": get_user_url(notification.mentioning_user, request), + "username": notification.mentioning_user.username, "user_display_name": notification.mentioning_user.display_name or notification.mentioning_user.username, "annotation_url": links.incontext_link(request, notification.annotation) @@ -18,6 +19,7 @@ def generate(request: Request, notification: MentionNotification): or notification.annotation.target_uri, "document_url": notification.annotation.target_uri, "annotation": notification.annotation, + "annotation_quote": quote.exact if quote else None, } subject = f"{context['user_display_name']} has mentioned you in an annotation" diff --git a/h/static/images/hypothesis-wordmark-logo.png b/h/static/images/hypothesis-wordmark-logo.png new file mode 100644 index 00000000000..43560202810 Binary files /dev/null and b/h/static/images/hypothesis-wordmark-logo.png differ diff --git a/h/templates/admin/mailer.html.jinja2 b/h/templates/admin/mailer.html.jinja2 index f2ed66fb3e3..7ad777c1f91 100644 --- a/h/templates/admin/mailer.html.jinja2 +++ b/h/templates/admin/mailer.html.jinja2 @@ -12,7 +12,7 @@ {% endif %} -
+

Send a test email

@@ -28,13 +28,13 @@
-
+

Preview the Mentions Email Template

diff --git a/h/templates/emails/mention_notification.html.jinja2 b/h/templates/emails/mention_notification.html.jinja2 index 47a5f251bbe..015ca740e98 100644 --- a/h/templates/emails/mention_notification.html.jinja2 +++ b/h/templates/emails/mention_notification.html.jinja2 @@ -1,26 +1,737 @@ -

- {% if user_url %} - {{ user_display_name }} - {% else %} - {{ user_display_name }} - {% endif %} - has - mentioned you - on - “{{ document_title }}”: -

- -

- On - {{ annotation.updated | human_timestamp }} - {% if user_url %} - {{ user_display_name }} - {% else %} - {{ user_display_name }} - {% endif %} - commented: -

- -
{{ (annotation.text or "")|striptags }}
- -

View the thread and respond.

+ + + + + + + + + There has been some activity in Hypothesis + + + +
+ + + + +
+ + + + + + + + + + +
+ + + + +
+ + + + +
+ + + + + + +
+ + + + + + +
+ +
+
+ + + + + + +
+ + + + + + +
+ +
+
+
+
+
+ + + + +
+ + + + + + + +
+ + + + +
+ + + + + + +
+ + + + + + + + +
+

+ {{ user_display_name or "@" ~ username }} mentioned you +

+
+ + +
+ + + + + + +
+ + + + + + + + +
+ +

{{ document_title }}

+ + + + + + + + +
+

@{{ username }}

+ + {% if annotation_quote %} +
+ {{ annotation_quote }} +
+ {% endif %} + +

{{ annotation.text_rendered | safe }}

+
+ +{#

We'd love your feedback so we can continue to make improvements#} +{# to our product. Take our survey#} +{# to tell us what you think of these new daily emails for#} +{# instructors.

#} + +
+ + +
+ {% if annotation_url %} + + + + + + +
+ + + + + + +
+ + View activity + +
+
+ {% endif %} +
+
+ +
+
+
+ + + + +
+ + + + +
+ + + + + + +
+ + + + + + + + +
+ Hypothesis, 2261 Market Street, #632, San Francisco, California 94114, United States of America
+{# Change your email preferences or unsubscribe from these emails.#} +
+ + +
+
+
+
+
+
+ + diff --git a/h/templates/emails/mention_notification.txt.jinja2 b/h/templates/emails/mention_notification.txt.jinja2 index e265df6947b..09042488052 100644 --- a/h/templates/emails/mention_notification.txt.jinja2 +++ b/h/templates/emails/mention_notification.txt.jinja2 @@ -1,7 +1,9 @@ -{{ user_display_name }} has mentioned you on "{{ document_title }}": +{{ user_display_name or '@' ~ username }} mentioned you on "{{ document_title }}": {{ document_url }} -On {{ annotation.updated | human_timestamp }} {{ user_display_name }} commented: +{% if annotation_quote %} +> {{ annotation_quote }} +{% endif %} -> {{ (annotation.text or "")|striptags }} +{{ (annotation.text or "")|striptags }} View the thread and respond: {{ annotation_url }} diff --git a/h/views/admin/mailer.py b/h/views/admin/mailer.py index e37d6540a18..d91ba2355f5 100644 --- a/h/views/admin/mailer.py +++ b/h/views/admin/mailer.py @@ -45,14 +45,13 @@ def mailer_test(request): ) def preview_mention_notification(_request): return { - "user_url": "https://example.com/user", + "username": "janedoe", "user_display_name": "Jane Doe", "annotation_url": "https://example.com/bouncer", # Bouncer link (AKA: annotation deeplink) - "document_title": "The title", + "document_title": "The document", "document_url": "https://example.com/document", # Document public URL "annotation": { - "updated": datetime(year=2025, month=1, day=11, hour=18, minute=36), # noqa: DTZ001 - "text": 'Hello @user, how are you?', "text_rendered": 'Hello @user, how are you?', }, + "annotation_quote": "This is a very important text" } diff --git a/tests/unit/h/views/admin/mailer_test.py b/tests/unit/h/views/admin/mailer_test.py index def6df6413a..5e986150aaa 100644 --- a/tests/unit/h/views/admin/mailer_test.py +++ b/tests/unit/h/views/admin/mailer_test.py @@ -59,15 +59,15 @@ def test_returns_dummy_data(self, pyramid_request): result == { "user_url": "https://example.com/user", + "username": "janedoe", "user_display_name": "Jane Doe", "annotation_url": "https://example.com/bouncer", # Bouncer link (AKA: annotation deeplink) - "document_title": "The title", + "document_title": "The document", "document_url": "https://example.com/document", # Document public URL "annotation": { - "updated": datetime(year=2025, month=1, day=11, hour=18, minute=36), # noqa: DTZ001 - "text": 'Hello @user, how are you?', "text_rendered": 'Hello @user, how are you?', }, + "annotation_quote": "This is a very important text" } )