mirror of
https://github.com/caronc/apprise.git
synced 2024-11-25 09:33:50 +01:00
Title now correctly applied to Matrix messages (#545)
This commit is contained in:
parent
259462efcc
commit
4cc5be0d6d
@ -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 '<h1>{}</h1>'.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 '<h1>{}</h1>'.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 '<h1>{}</h1>'.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 '<h1>{}</h1>'.format(
|
||||
NotifyMatrix.escape_html(title, whitespace=False)),
|
||||
body=markdown(body),
|
||||
)
|
||||
})
|
||||
|
||||
# Build our path
|
||||
|
Loading…
Reference in New Issue
Block a user