Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ntfy:// markdown support added #1056

Merged
merged 1 commit into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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