Add supplementary url support for pushover (#468)

This commit is contained in:
Spencer Phillip Young 2021-10-24 19:20:05 -07:00 committed by GitHub
parent e2ebdbdcf8
commit e8add7b95a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 1 deletions

View File

@ -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']

View File

@ -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,