Inconsistent Notification Plugin Information Cleanup (#889)

This commit is contained in:
Chris Caron 2023-06-24 15:25:05 -04:00 committed by GitHub
parent 3d36108446
commit ab55aef0d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
42 changed files with 140 additions and 44 deletions

4
.gitignore vendored
View File

@ -27,6 +27,10 @@ sdist/
.installed.cfg
*.egg
# Generated from Docker Instance
.bash_history
.python_history
# Installer logs
pip-log.txt
pip-delete-this-directory.txt

View File

@ -127,10 +127,10 @@ class NotifyBark(NotifyBase):
# Define object templates
templates = (
'{schema}://{host}/{targets}',
'{schema}://{host}:{port}/{targets}',
'{schema}://{user}:{password}@{host}/{targets}',
'{schema}://{user}:{password}@{host}:{port}/{targets}',
'{schema}://{user}:{password}@{host}/{targets}',
)
# Define our template arguments
@ -163,6 +163,7 @@ class NotifyBark(NotifyBase):
'targets': {
'name': _('Targets'),
'type': 'list:string',
'required': True,
},
})

View File

@ -151,6 +151,12 @@ class NotifyBoxcar(NotifyBase):
'to': {
'alias_of': 'targets',
},
'access': {
'alias_of': 'access_key',
},
'secret': {
'alias_of': 'secret_key',
},
})
def __init__(self, access, secret, targets=None, include_image=True,
@ -381,6 +387,16 @@ class NotifyBoxcar(NotifyBase):
results['targets'] += \
NotifyBoxcar.parse_list(results['qsd'].get('to'))
# Access
if 'access' in results['qsd'] and results['qsd']['access']:
results['access'] = NotifyBoxcar.unquote(
results['qsd']['access'].strip())
# Secret
if 'secret' in results['qsd'] and results['qsd']['secret']:
results['secret'] = NotifyBoxcar.unquote(
results['qsd']['secret'].strip())
# Include images with our message
results['include_image'] = \
parse_bool(results['qsd'].get('image', True))

View File

@ -121,11 +121,13 @@ class NotifyBulkSMS(NotifyBase):
'user': {
'name': _('User Name'),
'type': 'string',
'required': True,
},
'password': {
'name': _('Password'),
'type': 'string',
'private': True,
'required': True,
},
'target_phone': {
'name': _('Target Phone No'),
@ -144,6 +146,7 @@ class NotifyBulkSMS(NotifyBase):
'targets': {
'name': _('Targets'),
'type': 'list:string',
'required': True,
},
})

View File

@ -114,6 +114,7 @@ class NotifyD7Networks(NotifyBase):
'targets': {
'name': _('Targets'),
'type': 'list:string',
'required': True,
},
})

View File

@ -103,13 +103,18 @@ class NotifyDingTalk(NotifyBase):
'regex': (r'^[a-z0-9]+$', 'i'),
},
'secret': {
'name': _('Token'),
'name': _('Secret'),
'type': 'string',
'private': True,
'regex': (r'^[a-z0-9]+$', 'i'),
},
'targets': {
'target_phone_no': {
'name': _('Target Phone No'),
'type': 'string',
'map_to': 'targets',
},
'targets': {
'name': _('Targets'),
'type': 'list:string',
},
})

View File

@ -385,8 +385,13 @@ class NotifyEmail(NotifyBase):
'min': 1,
'max': 65535,
},
'target_email': {
'name': _('Target Email'),
'type': 'string',
'map_to': 'targets',
},
'targets': {
'name': _('Target Emails'),
'name': _('Targets'),
'type': 'list:string',
},
})

View File

@ -157,7 +157,6 @@ class NotifyFCM(NotifyBase):
'project': {
'name': _('Project ID'),
'type': 'string',
'required': True,
},
'target_device': {
'name': _('Target Device'),
@ -173,6 +172,7 @@ class NotifyFCM(NotifyBase):
'targets': {
'name': _('Targets'),
'type': 'list:string',
'required': True,
},
})

View File

@ -97,8 +97,8 @@ class NotifyFlock(NotifyBase):
# Define object templates
templates = (
'{schema}://{token}',
'{schema}://{user}@{token}',
'{schema}://{user}@{token}/{targets}',
'{schema}://{botname}@{token}',
'{schema}://{botname}@{token}/{targets}',
'{schema}://{token}/{targets}',
)
@ -111,9 +111,10 @@ class NotifyFlock(NotifyBase):
'private': True,
'required': True,
},
'user': {
'botname': {
'name': _('Bot Name'),
'type': 'string',
'map_to': 'user',
},
'to_user': {
'name': _('To User ID'),

View File

@ -122,9 +122,15 @@ class NotifyGitter(NotifyBase):
'required': True,
'regex': (r'^[a-z0-9]{40}$', 'i'),
},
'target_room': {
'name': _('Target Room'),
'type': 'string',
'map_to': 'targets',
},
'targets': {
'name': _('Rooms'),
'name': _('Targets'),
'type': 'list:string',
'required': True,
},
})

View File

@ -134,7 +134,6 @@ class NotifyGotify(NotifyBase):
'type': 'string',
'map_to': 'fullpath',
'default': '/',
'required': True,
},
'port': {
'name': _('Port'),

View File

@ -174,7 +174,6 @@ class NotifyJoin(NotifyBase):
'targets': {
'name': _('Targets'),
'type': 'list:string',
'required': True,
},
})

View File

@ -370,6 +370,7 @@ class NotifyLametric(NotifyBase):
# Device Mode
'{schema}://{apikey}@{host}',
'{schema}://{user}:{apikey}@{host}',
'{schema}://{apikey}@{host}:{port}',
'{schema}://{user}:{apikey}@{host}:{port}',
)
@ -404,7 +405,6 @@ class NotifyLametric(NotifyBase):
'host': {
'name': _('Hostname'),
'type': 'string',
'required': True,
},
'port': {
'name': _('Port'),

View File

@ -102,6 +102,7 @@ class NotifyLine(NotifyBase):
'targets': {
'name': _('Targets'),
'type': 'list:string',
'required': True
},
})

View File

@ -133,6 +133,7 @@ class NotifyMSG91(NotifyBase):
'targets': {
'name': _('Targets'),
'type': 'list:string',
'required': True,
},
'sender': {
'name': _('Sender ID'),

View File

@ -152,8 +152,13 @@ class NotifyMailgun(NotifyBase):
'private': True,
'required': True,
},
'target_email': {
'name': _('Target Email'),
'type': 'string',
'map_to': 'targets',
},
'targets': {
'name': _('Target Emails'),
'name': _('Targets'),
'type': 'list:string',
},
})

View File

@ -175,7 +175,6 @@ class NotifyMatrix(NotifyBase):
'host': {
'name': _('Hostname'),
'type': 'string',
'required': True,
},
'port': {
'name': _('Port'),
@ -194,6 +193,7 @@ class NotifyMatrix(NotifyBase):
},
'token': {
'name': _('Access Token'),
'private': True,
'map_to': 'password',
},
'target_user': {

View File

@ -91,11 +91,11 @@ class NotifyMattermost(NotifyBase):
# Define object templates
templates = (
'{schema}://{host}/{token}',
'{schema}://{host}/{token}:{port}',
'{schema}://{host}:{port}/{token}',
'{schema}://{host}/{fullpath}/{token}',
'{schema}://{host}:{port}/{fullpath}/{token}',
'{schema}://{botname}@{host}/{token}',
'{schema}://{botname}@{host}:{port}/{token}',
'{schema}://{host}/{fullpath}/{token}',
'{schema}://{host}/{fullpath}{token}:{port}',
'{schema}://{botname}@{host}/{fullpath}/{token}',
'{schema}://{botname}@{host}:{port}/{fullpath}/{token}',
)

View File

@ -67,6 +67,8 @@ class NotifyNextcloud(NotifyBase):
# Define object templates
templates = (
'{schema}://{host}/{targets}',
'{schema}://{host}:{port}/{targets}',
'{schema}://{user}:{password}@{host}/{targets}',
'{schema}://{user}:{password}@{host}:{port}/{targets}',
)

View File

@ -96,6 +96,11 @@ class NotifyNextcloudTalk(NotifyBase):
'private': True,
'required': True,
},
'target_room_id': {
'name': _('Room ID'),
'type': 'string',
'map_to': 'targets',
},
'targets': {
'name': _('Targets'),
'type': 'list:string',

View File

@ -112,12 +112,12 @@ class NotifyNotica(NotifyBase):
'{schema}://{user}:{password}@{host}:{port}/{token}',
# Self-hosted notica servers (with custom path)
'{schema}://{host}{path}{token}',
'{schema}://{host}:{port}{path}{token}',
'{schema}://{user}@{host}{path}{token}',
'{schema}://{user}@{host}:{port}{path}{token}',
'{schema}://{user}:{password}@{host}{path}{token}',
'{schema}://{user}:{password}@{host}:{port}{path}{token}',
'{schema}://{host}{path}/{token}',
'{schema}://{host}:{port}/{path}/{token}',
'{schema}://{user}@{host}/{path}/{token}',
'{schema}://{user}@{host}:{port}{path}/{token}',
'{schema}://{user}:{password}@{host}{path}/{token}',
'{schema}://{user}:{password}@{host}:{port}/{path}/{token}',
)
# Define our template tokens

View File

@ -148,8 +148,13 @@ class NotifyOffice365(NotifyBase):
'private': True,
'required': True,
},
'target_email': {
'name': _('Target Email'),
'type': 'string',
'map_to': 'targets',
},
'targets': {
'name': _('Target Emails'),
'name': _('Targets'),
'type': 'list:string',
},
})

View File

@ -146,6 +146,7 @@ class NotifyOneSignal(NotifyBase):
'targets': {
'name': _('Targets'),
'type': 'list:string',
'required': True,
},
})

View File

@ -142,7 +142,7 @@ class NotifyPagerDuty(NotifyBase):
},
# Optional but triggers V2 API
'integrationkey': {
'name': _('Routing Key'),
'name': _('Integration Key'),
'type': 'string',
'private': True,
'required': True

View File

@ -93,6 +93,7 @@ class NotifyPopcornNotify(NotifyBase):
'targets': {
'name': _('Targets'),
'type': 'list:string',
'required': True,
}
})

View File

@ -186,6 +186,7 @@ class NotifyReddit(NotifyBase):
'targets': {
'name': _('Targets'),
'type': 'list:string',
'required': True,
},
})

View File

@ -91,7 +91,7 @@ class NotifyRyver(NotifyBase):
# Define object templates
templates = (
'{schema}://{organization}/{token}',
'{schema}://{user}@{organization}/{token}',
'{schema}://{botname}@{organization}/{token}',
)
# Define our template tokens
@ -109,9 +109,10 @@ class NotifyRyver(NotifyBase):
'private': True,
'regex': (r'^[A-Z0-9]{15}$', 'i'),
},
'user': {
'botname': {
'name': _('Bot Name'),
'type': 'string',
'map_to': 'user',
},
})

View File

@ -174,6 +174,7 @@ class NotifySES(NotifyBase):
'name': _('Region'),
'type': 'string',
'regex': (r'^[a-z]{2}-[a-z-]+?-[0-9]+$', 'i'),
'required': True,
'map_to': 'region_name',
},
'targets': {

View File

@ -145,6 +145,7 @@ class NotifySMSEagle(NotifyBase):
'token': {
'name': _('Access Token'),
'type': 'string',
'required': True,
},
'target_phone': {
'name': _('Target Phone No'),
@ -170,6 +171,7 @@ class NotifySMSEagle(NotifyBase):
'targets': {
'name': _('Targets'),
'type': 'list:string',
'required': True,
}
})

View File

@ -103,7 +103,7 @@ class NotifySNS(NotifyBase):
# Define object templates
templates = (
'{schema}://{access_key_id}/{secret_access_key}{region}/{targets}',
'{schema}://{access_key_id}/{secret_access_key}/{region}/{targets}',
)
# Define our template tokens
@ -125,6 +125,7 @@ class NotifySNS(NotifyBase):
'type': 'string',
'required': True,
'regex': (r'^[a-z]{2}-[a-z-]+?-[0-9]+$', 'i'),
'required': True,
'map_to': 'region_name',
},
'target_phone_no': {

View File

@ -68,7 +68,7 @@ class NotifyServerChan(NotifyBase):
# Define object templates
templates = (
'{schema}://{token}/',
'{schema}://{token}',
)
# Define our template tokens

View File

@ -109,12 +109,12 @@ class NotifySimplePush(NotifyBase):
# Used for encrypted logins
'password': {
'name': _('Encrypted Password'),
'name': _('Password'),
'type': 'string',
'private': True,
},
'salt': {
'name': _('Encrypted Salt'),
'name': _('Salt'),
'type': 'string',
'private': True,
'map_to': 'user',

View File

@ -165,10 +165,10 @@ class NotifySlack(NotifyBase):
# Define object templates
templates = (
# Webhook
'{schema}://{token_a}/{token_b}{token_c}',
'{schema}://{token_a}/{token_b}/{token_c}',
'{schema}://{botname}@{token_a}/{token_b}{token_c}',
'{schema}://{token_a}/{token_b}{token_c}/{targets}',
'{schema}://{botname}@{token_a}/{token_b}{token_c}/{targets}',
'{schema}://{token_a}/{token_b}/{token_c}/{targets}',
'{schema}://{botname}@{token_a}/{token_b}/{token_c}/{targets}',
# Bot
'{schema}://{access_token}/',
@ -198,7 +198,6 @@ class NotifySlack(NotifyBase):
'name': _('Token A'),
'type': 'string',
'private': True,
'required': True,
'regex': (r'^[A-Z0-9]+$', 'i'),
},
# Token required as part of the Webhook request
@ -207,7 +206,6 @@ class NotifySlack(NotifyBase):
'name': _('Token B'),
'type': 'string',
'private': True,
'required': True,
'regex': (r'^[A-Z0-9]+$', 'i'),
},
# Token required as part of the Webhook request
@ -216,7 +214,6 @@ class NotifySlack(NotifyBase):
'name': _('Token C'),
'type': 'string',
'private': True,
'required': True,
'regex': (r'^[A-Za-z0-9]+$', 'i'),
},
'target_encoded_id': {

View File

@ -135,7 +135,6 @@ class NotifySpontit(NotifyBase):
'targets': {
'name': _('Targets'),
'type': 'list:string',
'required': True,
},
})

View File

@ -165,7 +165,6 @@ class NotifySyslog(NotifyBase):
'host': {
'name': _('Hostname'),
'type': 'string',
'required': True,
},
'port': {
'name': _('Port'),

View File

@ -106,10 +106,12 @@ class NotifyTwist(NotifyBase):
'name': _('Password'),
'type': 'string',
'private': True,
'required': True,
},
'email': {
'name': _('Email'),
'type': 'string',
'required': True,
},
'target_channel': {
'name': _('Target Channel'),

View File

@ -132,6 +132,7 @@ class NotifyTwitter(NotifyBase):
ratelimit_remaining = 1
templates = (
'{schema}://{ckey}/{csecret}/{akey}/{asecret}',
'{schema}://{ckey}/{csecret}/{akey}/{asecret}/{targets}',
)

View File

@ -78,7 +78,6 @@ class NotifyVoipms(NotifyBase):
# Define object templates
templates = (
'{schema}://{password}:{email}',
'{schema}://{password}:{email}/{from_phone}/{targets}',
)
@ -111,6 +110,7 @@ class NotifyVoipms(NotifyBase):
'targets': {
'name': _('Targets'),
'type': 'list:string',
'required': True,
},
})

View File

@ -131,6 +131,7 @@ class NotifyZulip(NotifyBase):
'name': _('Bot Name'),
'type': 'string',
'regex': (r'^[A-Z0-9_-]{1,32}$', 'i'),
'required': True,
},
'organization': {
'name': _('Organization'),

View File

@ -165,6 +165,9 @@ def _sanitize_token(tokens, default_delimiter):
"""
# Used for tracking groups
group_map = {}
# Iterate over our tokens
for key in tokens.keys():
@ -181,15 +184,28 @@ def _sanitize_token(tokens, default_delimiter):
# Default type to key
tokens[key]['map_to'] = key
# Track our map_to objects
if tokens[key]['map_to'] not in group_map:
group_map[tokens[key]['map_to']] = set()
group_map[tokens[key]['map_to']].add(key)
if 'type' not in tokens[key]:
# Default type to string
tokens[key]['type'] = 'string'
elif tokens[key]['type'].startswith('list') \
and 'delim' not in tokens[key]:
elif tokens[key]['type'].startswith('list'):
if 'delim' not in tokens[key]:
# Default list delimiter (if not otherwise specified)
tokens[key]['delim'] = default_delimiter
if key in group_map[tokens[key]['map_to']]: # pragma: no branch
# Remove ourselves from the list
group_map[tokens[key]['map_to']].remove(key)
# Pointing to the set directly so we can dynamically update
# ourselves
tokens[key]['group'] = group_map[tokens[key]['map_to']]
elif tokens[key]['type'].startswith('choice') \
and 'default' not in tokens[key] \
and 'values' in tokens[key] \
@ -266,6 +282,13 @@ def details(plugin):
# # Identifies if the entry specified is required or not
# 'required': True,
#
# # Identifies all tokens detected to be associated with the
# # list:string
# # This is ony present in list:string objects and is only set
# # if this element acts as an alias for several other
# # kwargs/fields.
# 'group': [],
#
# # Identify a default value
# 'default': 'http',
#

View File

@ -1486,6 +1486,7 @@ def test_apprise_details_plugin_verification():
valid_schema_keys = (
'name', 'private', 'required', 'type', 'values', 'min', 'max',
'regex', 'default', 'list', 'delim', 'prefix', 'map_to', 'alias_of',
'group',
)
for entry in details['schemas']:

View File

@ -89,6 +89,12 @@ apprise_url_tests = (
'instance': NotifyBoxcar,
'requests_response_code': requests.codes.created,
}),
('boxcar://?access=%s&secret=%s&to=tag5' % ('d' * 64, 'b' * 64), {
# Test access and secret kwargs
'privacy_url': 'boxcar://d...d/****/',
'instance': NotifyBoxcar,
'requests_response_code': requests.codes.created,
}),
# An invalid tag
('boxcar://%s/%s/@%s' % ('a' * 64, 'b' * 64, 't' * 64), {
'instance': NotifyBoxcar,