mirror of
https://github.com/caronc/apprise.git
synced 2025-02-10 15:30:35 +01:00
ntfy:// markdown support added (#1056)
This commit is contained in:
parent
31a4f2e735
commit
e9beea22bc
@ -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
|
||||||
|
|
||||||
|
@ -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')
|
||||||
|
Loading…
Reference in New Issue
Block a user