From e8add7b95ae524bfdab6bc7bd8e0db29e5b63eaa Mon Sep 17 00:00:00 2001 From: Spencer Phillip Young Date: Sun, 24 Oct 2021 19:20:05 -0700 Subject: [PATCH] Add supplementary url support for pushover (#468) --- apprise/plugins/NotifyPushover.py | 23 ++++++++++++++++++++++- test/test_rest_plugins.py | 4 ++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/apprise/plugins/NotifyPushover.py b/apprise/plugins/NotifyPushover.py index 5e226fc2..f3a49d1f 100644 --- a/apprise/plugins/NotifyPushover.py +++ b/apprise/plugins/NotifyPushover.py @@ -196,6 +196,14 @@ class NotifyPushover(NotifyBase): 'regex': (r'^[a-z]{1,12}$', 'i'), 'default': PushoverSound.PUSHOVER, }, + 'url': { + 'name': _('URL'), + 'type': 'string', + }, + 'url_title': { + 'name': _('URL Title'), + 'type': 'string' + }, 'retry': { 'name': _('Retry'), 'type': 'int', @@ -215,7 +223,8 @@ class NotifyPushover(NotifyBase): }) def __init__(self, user_key, token, targets=None, priority=None, - sound=None, retry=None, expire=None, **kwargs): + sound=None, retry=None, expire=None, url=None, + url_title=None, **kwargs): """ Initialize Pushover Object """ @@ -241,6 +250,10 @@ class NotifyPushover(NotifyBase): if len(self.targets) == 0: self.targets = (PUSHOVER_SEND_TO_ALL, ) + # Setup supplemental url + self.supplemental_url = url + self.supplemental_url_title = url_title + # Setup our sound self.sound = NotifyPushover.default_pushover_sound \ if not isinstance(sound, six.string_types) else sound.lower() @@ -319,6 +332,8 @@ class NotifyPushover(NotifyBase): 'message': body, 'device': device, 'sound': self.sound, + 'url': self.supplemental_url, + 'url_title': self.supplemental_url_title } if self.notify_format == NotifyFormat.HTML: @@ -569,6 +584,12 @@ class NotifyPushover(NotifyBase): results['sound'] = \ NotifyPushover.unquote(results['qsd']['sound']) + # Get the supplementary url + if 'url' in results['qsd'] and len(results['qsd']['url']): + results['url'] = NotifyPushover.unquote(results['qsd']['url']) + if 'url_title' in results['qsd'] and len(results['qsd']['url_title']): + results['url_title'] = results['qsd']['url_title'] + # Get expire and retry if 'expire' in results['qsd'] and len(results['qsd']['expire']): results['expire'] = results['qsd']['expire'] diff --git a/test/test_rest_plugins.py b/test/test_rest_plugins.py index 6eee9bd9..261877d1 100644 --- a/test/test_rest_plugins.py +++ b/test/test_rest_plugins.py @@ -3581,6 +3581,10 @@ TEST_URLS = ( ('pover://%s@%s?sound=spacealarm' % ('u' * 30, 'a' * 30), { 'instance': plugins.NotifyPushover, }), + # API Key + valid url_title with url + ('pover://%s@%s?url=my-url&url_title=title' % ('u' * 30, 'a' * 30), { + 'instance': plugins.NotifyPushover, + }), # API Key + Valid User ('pover://%s@%s' % ('u' * 30, 'a' * 30), { 'instance': plugins.NotifyPushover,