diff --git a/notifications_consumer/processors/mattermost/utils.py b/notifications_consumer/processors/mattermost/utils.py index 43966266af682ebe76550dde34c955b4157a9ab1..9a784dcbfe44d656c29f65c365df8622d913378d 100644 --- a/notifications_consumer/processors/mattermost/utils.py +++ b/notifications_consumer/processors/mattermost/utils.py @@ -1,7 +1,5 @@ """Mattermost notifications utils.""" -import html import logging -import re import unicodedata from mattermostdriver import Driver @@ -11,8 +9,8 @@ from notifications_consumer.config import Config def create_message(summary: str, body: str, url: str, image: str): """Create json blob to be sent via Mattermost.""" - # strip tags, html decode and replace unicode blobs - text_content = unicodedata.normalize("NFKD", html.unescape(re.sub("<.*?>", "", body))) + # Replace unicode blobs + text_content = unicodedata.normalize("NFKD", body) # If message is empty string, webpush will fill with the ugly json message if not text_content: text_content = "empty" diff --git a/scripts/docker-send-mattermost.py b/scripts/docker-send-mattermost.py index 9a363c98b80d9e6082a795e9969201483bfd2309..595c7b77bfeedd2d305476974e600d5ddcae2a15 100644 --- a/scripts/docker-send-mattermost.py +++ b/scripts/docker-send-mattermost.py @@ -6,14 +6,14 @@ conn = stomp.Connection([("activemq", 61613)]) conn.connect("admin", "admin", wait=True) message_body = r"""{ "channel_name": "The Best Notifications", -"content":"<p>This is an <a href=\"http://example.com/\">example link</a>.</p><!-- This comment --><code>/home/\nhi" - "codeline2\ncodeline3</code>\n<img src=\"img_girl.jpg\" alt=\"Girl" +"message_body":"<p>This is an <a href=\"http://example.com/\">example link</a>.</p><!--" + "This comment --><code>/home/\nhicodeline2\ncodeline3</code>\n<img src=\"img_girl.jpg\" alt=\"Girl" " in a jacket\" width=\"500\" height=\"600\">\n<h1>Hello</h1>\n<h2>Hello</h2>", "summary": "sub test EO", "link": "http://cds.cern.ch/record/2687667", "img_url": "http://cds.cern.ch/record/2687667/files/CLICtd.png?subformat=icon-640", -"device_token": "emmanuel.ormancey@cern.ch", -"email": "emmanuel.ormancey@cern.ch", +"device_token": "caetan.tojeiro.carpente@cern.ch", +"email": "caetan.tojeiro.carpente@cern.ch", "device_id": "084a9172-cc5d-451a-b573-c5baafc1257c", "notification_id": "kujasdhdkjszhdghello" }"""