From b630b7ab6eb051e4f7462f0eb00b435b0658d829 Mon Sep 17 00:00:00 2001 From: Chris Caron Date: Sat, 19 Aug 2023 15:02:23 -0400 Subject: [PATCH] token= and push_key= support added --- apprise/plugins/NotifyPushMe.py | 18 ++++++++++++++++++ test/test_plugin_pushme.py | 14 ++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/apprise/plugins/NotifyPushMe.py b/apprise/plugins/NotifyPushMe.py index 5fc083677f..d5e5ed46f1 100644 --- a/apprise/plugins/NotifyPushMe.py +++ b/apprise/plugins/NotifyPushMe.py @@ -74,6 +74,16 @@ class NotifyPushMe(NotifyBase): }, }) + # Define our template arguments + template_args = dict(NotifyBase.template_args, **{ + 'token': { + 'alias_of': 'token', + }, + 'push_key': { + 'alias_of': 'token', + }, + }) + def __init__(self, token, **kwargs): """ Initialize PushMe Object @@ -185,4 +195,12 @@ def parse_url(url): # Store our token using the host results['token'] = NotifyPushMe.unquote(results['host']) + # The 'token' makes it easier to use yaml configuration + if 'token' in results['qsd'] and len(results['qsd']['token']): + results['token'] = NotifyPushMe.unquote(results['qsd']['token']) + + elif 'push_key' in results['qsd'] and len(results['qsd']['push_key']): + # Support 'push_key' if specified + results['token'] = NotifyPushMe.unquote(results['qsd']['push_key']) + return results diff --git a/test/test_plugin_pushme.py b/test/test_plugin_pushme.py index bbc30af1e6..ab7117aff3 100644 --- a/test/test_plugin_pushme.py +++ b/test/test_plugin_pushme.py @@ -54,6 +54,20 @@ # Our expected url(privacy=True) startswith() response: 'privacy_url': 'pushme://a...a/', }), + # Token specified + ('pushme://?token=%s' % ('b' * 6), { + 'instance': NotifyPushMe, + + # Our expected url(privacy=True) startswith() response: + 'privacy_url': 'pushme://b...b/', + }), + # Token specified + ('pushme://?push_key=%s' % ('p' * 6), { + 'instance': NotifyPushMe, + + # Our expected url(privacy=True) startswith() response: + 'privacy_url': 'pushme://p...p/', + }), ('pushme://%s' % ('c' * 6), { 'instance': NotifyPushMe, # force a failure