From 4cc5be0d6d843bd6a3fcfac54139f15e0e656093 Mon Sep 17 00:00:00 2001 From: Chris Caron Date: Sat, 26 Mar 2022 19:49:07 -0400 Subject: [PATCH] Title now correctly applied to Matrix messages (#545) --- apprise/plugins/NotifyMatrix.py | 45 +++++++++++++-------------------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/apprise/plugins/NotifyMatrix.py b/apprise/plugins/NotifyMatrix.py index 8b7c6eb4..c739e51e 100644 --- a/apprise/plugins/NotifyMatrix.py +++ b/apprise/plugins/NotifyMatrix.py @@ -42,7 +42,6 @@ from ..common import NotifyImageSize from ..common import NotifyFormat from ..utils import parse_bool from ..utils import parse_list -from ..utils import apply_template from ..utils import is_hostname from ..utils import validate_regex from ..AppriseLocale import gettext_lazy as _ @@ -470,21 +469,16 @@ class NotifyMatrix(NotifyBase): } if self.notify_format == NotifyFormat.HTML: - # Add additional information to our content; use {{app_title}} - # to apply the title to the html body - tokens = { - 'app_title': NotifyMatrix.escape_html( - title, whitespace=False), - } - payload['text'] = apply_template(body, **tokens) + payload['text'] = '{title}{body}'.format( + title='' if not title else '

{}

'.format( + NotifyMatrix.escape_html(title)), + body=body) elif self.notify_format == NotifyFormat.MARKDOWN: - # Add additional information to our content; use {{app_title}} - # to apply the title to the html body - tokens = { - 'app_title': title, - } - payload['text'] = markdown(apply_template(body, **tokens)) + payload['text'] = '{title}{body}'.format( + title='' if not title else '

{}

'.format( + NotifyMatrix.escape_html(title)), + body=markdown(body)) else: # NotifyFormat.TEXT payload['text'] = \ @@ -583,32 +577,29 @@ class NotifyMatrix(NotifyBase): payload = { 'msgtype': 'm.{}'.format(self.msgtype), 'body': '{title}{body}'.format( - title='' if not title else '{}\r\n'.format(title), + title='' if not title else '# {}\r\n'.format(title), body=body), } # Update our payload advance formatting for the services that # support them. if self.notify_format == NotifyFormat.HTML: - # Add additional information to our content; use {{app_title}} - # to apply the title to the html body - tokens = { - 'app_title': NotifyMatrix.escape_html( - title, whitespace=False), - } - payload.update({ 'format': 'org.matrix.custom.html', - 'formatted_body': apply_template(body, **tokens), + 'formatted_body': '{title}{body}'.format( + title='' if not title else '

{}

'.format(title), + body=body, + ) }) elif self.notify_format == NotifyFormat.MARKDOWN: - tokens = { - 'app_title': title, - } payload.update({ 'format': 'org.matrix.custom.html', - 'formatted_body': markdown(apply_template(body, **tokens)) + 'formatted_body': '{title}{body}'.format( + title='' if not title else '

{}

'.format( + NotifyMatrix.escape_html(title, whitespace=False)), + body=markdown(body), + ) }) # Build our path