From d6a3e7d403cece7b30a3a74174079de06ab94ac8 Mon Sep 17 00:00:00 2001 From: Emmanuel Ormancey <emmanuel.ormancey@cern.ch> Date: Wed, 5 May 2021 14:40:49 +0200 Subject: [PATCH] fixed summary link and channel url --- notifications_consumer/processors/email/processor.py | 2 ++ .../processors/email/templates/notification_body.html | 4 +++- .../processors/email/templates/simple_notification.html | 2 +- scripts/send-email.py | 9 ++++++++- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/notifications_consumer/processors/email/processor.py b/notifications_consumer/processors/email/processor.py index d3e710f..c25f8bc 100644 --- a/notifications_consumer/processors/email/processor.py +++ b/notifications_consumer/processors/email/processor.py @@ -38,6 +38,8 @@ class EmailProcessor(Processor): "sender": Config.SERVICE_NAME, "channel_name": kwargs["channel_name"], "summary": kwargs["summary"], + "channel_id": kwargs["channel_id"], + "link": kwargs["link"], } text_template = Config.TEMPLATES.get_template("email/simple_notification.txt") diff --git a/notifications_consumer/processors/email/templates/notification_body.html b/notifications_consumer/processors/email/templates/notification_body.html index 4fd4ec3..025cb7b 100644 --- a/notifications_consumer/processors/email/templates/notification_body.html +++ b/notifications_consumer/processors/email/templates/notification_body.html @@ -1,7 +1,9 @@ <table border="0" cellpadding="0" cellspacing="0" style="border-radius: 5px; background: #f9f9f9; min-width: 550px;"> <td style="padding:10px"> <p style="line-height: 145%;"> - <b><span style="color: #3071AB;">{{ summary }}</span></b> + <a style="text-decoration:none" href="{{ link }}"> + <b><span style="color: #3071AB;">{{ summary }}</span></b> + </a> </p> </td> <tr> diff --git a/notifications_consumer/processors/email/templates/simple_notification.html b/notifications_consumer/processors/email/templates/simple_notification.html index ad13123..703cb4e 100644 --- a/notifications_consumer/processors/email/templates/simple_notification.html +++ b/notifications_consumer/processors/email/templates/simple_notification.html @@ -4,7 +4,7 @@ <table width="100%"> <tr style="background: #3071AB;text-align: center;color:white;"> <td style="padding:10px"> - <a style="text-decoration:none" href="{{ base_url }}/channels/notifications"> + <a style="text-decoration:none" href="{{ base_url }}/channels/{{channel_id}}/notifications"> <h3 style="color: white; margin: 0;"> {{ channel_name }} </h3> diff --git a/scripts/send-email.py b/scripts/send-email.py index b014ae8..9c2e806 100644 --- a/scripts/send-email.py +++ b/scripts/send-email.py @@ -4,6 +4,13 @@ import stomp conn = stomp.Connection([("localhost", 61613)]) conn.connect("admin", "admin", wait=True) -message_body = r"""{"message_body":"My message body","summary":"My summary","email":"test@cern.ch"}""" +message_body = r"""{ +"message_body":"My message body", +"summary":"My summary", +"email":"user@cern.ch", +"link":"http://toto.cern.ch", +"channel_name":"zename", +"channel_id":"123" +}""" conn.send(body=message_body, destination="/queue/np.email", headers={"persistent": "true"}) conn.disconnect() -- GitLab