ntfy:// markdown support added (#1056)

This commit is contained in:
Chris Caron 2024-02-03 13:26:12 -05:00 committed by GitHub
parent 31a4f2e735
commit e9beea22bc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 0 deletions

View File

@ -42,6 +42,7 @@ from json import dumps
from os.path import basename from os.path import basename
from .NotifyBase import NotifyBase from .NotifyBase import NotifyBase
from ..common import NotifyFormat
from ..common import NotifyType from ..common import NotifyType
from ..common import NotifyImageSize from ..common import NotifyImageSize
from ..AppriseLocale import gettext_lazy as _ from ..AppriseLocale import gettext_lazy as _
@ -515,6 +516,10 @@ class NotifyNtfy(NotifyBase):
if body: if body:
virt_payload['message'] = body virt_payload['message'] = body
if self.notify_format == NotifyFormat.MARKDOWN:
# Support Markdown
headers['X-Markdown'] = 'yes'
if self.priority != NtfyPriority.NORMAL: if self.priority != NtfyPriority.NORMAL:
headers['X-Priority'] = self.priority headers['X-Priority'] = self.priority

View File

@ -487,6 +487,22 @@ def test_plugin_custom_ntfy_edge_cases(mock_post):
assert response['attach'] == 'http://example.com/file.jpg' assert response['attach'] == 'http://example.com/file.jpg'
assert response['filename'] == 'smoke.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.post')
@mock.patch('requests.get') @mock.patch('requests.get')