Skip to content

Commit

Permalink
ntfy:// markdown support added
Browse files Browse the repository at this point in the history
  • Loading branch information
caronc committed Feb 3, 2024
1 parent 31a4f2e commit 382dce5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions apprise/plugins/NotifyNtfy.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
from os.path import basename

from .NotifyBase import NotifyBase
from ..common import NotifyFormat
from ..common import NotifyType
from ..common import NotifyImageSize
from ..AppriseLocale import gettext_lazy as _
Expand Down Expand Up @@ -515,6 +516,10 @@ def _send(self, topic, body=None, title=None, attach=None, image_url=None,
if body:
virt_payload['message'] = body

if self.notify_format == NotifyFormat.MARKDOWN:
# Support Markdown
headers['X-Markdown'] = 'yes'

if self.priority != NtfyPriority.NORMAL:
headers['X-Priority'] = self.priority

Expand Down
16 changes: 16 additions & 0 deletions test/test_plugin_ntfy.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,22 @@ def test_plugin_custom_ntfy_edge_cases(mock_post):
assert response['attach'] == 'http://example.com/file.jpg'
assert response['filename'] == 'smoke.jpg'

# Reset our mock object
mock_post.reset_mock()

# Markdown Support
results = NotifyNtfy.parse_url('ntfys://topic/?format=markdown')
assert isinstance(results, dict)
instance = NotifyNtfy(**results)

assert instance.notify(
body='body', title='title',
notify_type=apprise.NotifyType.INFO) is True

assert mock_post.call_count == 1
assert mock_post.call_args_list[0][0][0] == 'https://ntfy.sh'
assert 'X-Markdown' in mock_post.call_args_list[0][1]['headers']


@mock.patch('requests.post')
@mock.patch('requests.get')
Expand Down

0 comments on commit 382dce5

Please sign in to comment.