Skip to content

Commit

Permalink
Add admin route to preview mentions email
Browse files Browse the repository at this point in the history
  • Loading branch information
acelaya committed Feb 17, 2025
1 parent 0c572cf commit e8b790c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions h/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ def includeme(config): # noqa: PLR0915
)
config.add_route("admin.mailer", "/admin/mailer")
config.add_route("admin.mailer_test", "/admin/mailer/test")
config.add_route(
"admin.mailer.preview.mention_notification",
"/admin/mailer/preview/mention-notification",
)
config.add_route("admin.nipsa", "/admin/nipsa")
config.add_route("admin.oauthclients", "/admin/oauthclients")
config.add_route("admin.oauthclients_create", "/admin/oauthclients/new")
Expand Down
23 changes: 23 additions & 0 deletions h/views/admin/mailer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from datetime import datetime

from pyramid.httpexceptions import HTTPSeeOther
from pyramid.view import view_config

Expand Down Expand Up @@ -33,3 +35,24 @@ def mailer_test(request):
result = mailer.send.delay(*mail)
index = request.route_path("admin.mailer", _query={"taskid": result.task_id})
return HTTPSeeOther(location=index)


@view_config(
route_name="admin.mailer.preview.mention_notification",
request_method="GET",
permission=Permission.AdminPage.LOW_RISK,
renderer="h:templates/emails/mention_notification.html.jinja2",
)
def preview_mention_notification(request):
return {
"user_url": "https://example.com/user", # TODO
"user_display_name": "Jane Doe",
"annotation_url": "https://example.com/bouncer", # TODO Bouncer link -> annotation deeplink
"document_title": "The title",
"document_url": "https://example.com/document", # TODO Document public URL
"annotation": {
"updated": datetime.now(),
"text": 'Hello <a data-hyp-mention data-userid="acct:user@example.com">@user</a>, how are you?',
"text_rendered": 'Hello <a data-hyp-mention data-userid="acct:user@example.com">@user</a>, how are you?',
},
}

0 comments on commit e8b790c

Please sign in to comment.