OneSignal code cleanup

pull/342/head
Chris Caron 2020-12-30 16:29:23 -05:00
parent ed04898ec4
commit 4037d8726e
2 changed files with 17 additions and 1 deletions

View File

@ -396,6 +396,7 @@ class NotifyOneSignal(NotifyBase):
# Define any URL parameters # Define any URL parameters
params = { params = {
'image': 'yes' if self.include_image else 'no', 'image': 'yes' if self.include_image else 'no',
'batch': 'yes' if self.batch_size > 1 else 'no',
} }
# Extend our parameters # Extend our parameters
@ -453,10 +454,17 @@ class NotifyOneSignal(NotifyBase):
'image', 'image',
NotifyOneSignal.template_args['image']['default'])) NotifyOneSignal.template_args['image']['default']))
# Get Batch Boolean (if set)
results['batch'] = \
parse_bool(
results['qsd'].get(
'batch',
NotifyOneSignal.template_args['batch']['default']))
# The API Key is stored in the hostname # The API Key is stored in the hostname
results['apikey'] = NotifyOneSignal.unquote(results['host']) results['apikey'] = NotifyOneSignal.unquote(results['host'])
# Get our Device IDs # Get our Targets
results['targets'] = NotifyOneSignal.split_path(results['fullpath']) results['targets'] = NotifyOneSignal.split_path(results['fullpath'])
# The 'to' makes it easier to use yaml configuration # The 'to' makes it easier to use yaml configuration

View File

@ -2371,6 +2371,14 @@ TEST_URLS = (
# Test to= # Test to=
'instance': plugins.NotifyOneSignal, 'instance': plugins.NotifyOneSignal,
}), }),
('onesignal://appid@apikey/#segment/@user/?batch=yes', {
# Test batch=
'instance': plugins.NotifyOneSignal,
}),
('onesignal://appid@apikey/#segment/@user/?batch=no', {
# Test batch=
'instance': plugins.NotifyOneSignal,
}),
('onesignal://templateid:appid@apikey/playerid', { ('onesignal://templateid:appid@apikey/playerid', {
# Test Template ID # Test Template ID
'instance': plugins.NotifyOneSignal, 'instance': plugins.NotifyOneSignal,