Skip to content

Commit

Permalink
reverted text handing to continue to be plain looking
Browse files Browse the repository at this point in the history
  • Loading branch information
caronc committed Aug 21, 2021
1 parent 3f48318 commit 6da94ad
Showing 1 changed file with 21 additions and 23 deletions.
44 changes: 21 additions & 23 deletions apprise/plugins/NotifyMatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,16 +432,16 @@ def _matrix_webhook_payload(self, body, title='',
payload['text'] = apply_template(body, **tokens)

elif self.notify_format == NotifyFormat.MARKDOWN:
if title:
payload['text'] = \
'<h4>{}</h4>'.format(
NotifyMatrix.escape_html(title, whitespace=False))

payload['text'] += markdown(body)
# 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))

else: # TEXT
payload['text'] = '{}{}'.format(
'' if not title else '{}\r\n'.format(title), body)
else: # NotifyFormat.TEXT
payload['text'] = \
body if not title else '{}\r\n{}'.format(title, body)

return payload

Expand Down Expand Up @@ -538,8 +538,6 @@ def _send_server_notification(self, body, title='',
'body': '{title}{body}'.format(
title='' if not title else '{}\r\n'.format(title),
body=body),
'format': 'org.matrix.custom.html',
'formatted_body': '',
}

# Update our payload advance formatting for the services that
Expand All @@ -551,20 +549,20 @@ def _send_server_notification(self, body, title='',
'app_title': NotifyMatrix.escape_html(
title, whitespace=False),
}
payload['formatted_body'] = apply_template(body, **tokens)

else: # TEXT or MARKDOWN
if title:
payload['formatted_body'] = \
'<h4>{}</h4>'.format(
NotifyMatrix.escape_html(title, whitespace=False))

if self.notify_format == NotifyFormat.TEXT:
payload['formatted_body'] += \
NotifyMatrix.escape_html(body, whitespace=False)
payload.update({
'format': 'org.matrix.custom.html',
'formatted_body': apply_template(body, **tokens),
})

else: # NotifyFormat.MARKDOWN
payload['formatted_body'] += markdown(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))
})

# Build our path
path = '/rooms/{}/send/m.room.message'.format(
Expand Down

0 comments on commit 6da94ad

Please sign in to comment.