Add android app notification priority option

This commit is contained in:
JonnyWong16 2017-03-29 22:32:56 -07:00
commit 441c56854d

View file

@ -64,6 +64,7 @@ import request
from plexpy.config import _BLACKLIST_KEYS, _WHITELIST_KEYS from plexpy.config import _BLACKLIST_KEYS, _WHITELIST_KEYS
from plexpy.helpers import checked from plexpy.helpers import checked
AGENT_IDS = {'growl': 0, AGENT_IDS = {'growl': 0,
'prowl': 1, 'prowl': 1,
'xbmc': 2, 'xbmc': 2,
@ -692,7 +693,8 @@ class ANDROIDAPP(Notifier):
""" """
PlexPy Android app notifications PlexPy Android app notifications
""" """
_DEFAULT_CONFIG = {'device_id': '' _DEFAULT_CONFIG = {'device_id': '',
'priority': 3
} }
ONESIGNAL_APP_ID = '3b4b666a-d557-4b92-acdf-e2c8c4b95357' ONESIGNAL_APP_ID = '3b4b666a-d557-4b92-acdf-e2c8c4b95357'
@ -702,7 +704,8 @@ class ANDROIDAPP(Notifier):
return return
plaintext_data = {'subject': subject.encode("utf-8"), plaintext_data = {'subject': subject.encode("utf-8"),
'body': body.encode("utf-8")} 'body': body.encode("utf-8"),
'priority': self.config['priority']}
logger.debug("Plaintext data: {}".format(plaintext_data)) logger.debug("Plaintext data: {}".format(plaintext_data))
@ -733,7 +736,7 @@ class ANDROIDAPP(Notifier):
'data': {'cipher_text': base64.b64encode(encrypted_data), 'data': {'cipher_text': base64.b64encode(encrypted_data),
'gcm_tag': base64.b64encode(gcm_tag), 'gcm_tag': base64.b64encode(gcm_tag),
'nonce': base64.b64encode(nonce), 'nonce': base64.b64encode(nonce),
'salt': base64.b64encode(salt)}, 'salt': base64.b64encode(salt)}
} }
else: else:
logger.warn(u"PlexPy Notifiers :: PyCryptodome library is missing. " logger.warn(u"PlexPy Notifiers :: PyCryptodome library is missing. "
@ -743,7 +746,7 @@ class ANDROIDAPP(Notifier):
payload = {'app_id': self.ONESIGNAL_APP_ID, payload = {'app_id': self.ONESIGNAL_APP_ID,
'include_player_ids': [self.config['device_id']], 'include_player_ids': [self.config['device_id']],
'contents': {'en': 'PlexPy Notification'}, 'contents': {'en': 'PlexPy Notification'},
'data': plaintext_data, 'data': plaintext_data
} }
logger.debug("OneSignal payload: {}".format(payload)) logger.debug("OneSignal payload: {}".format(payload))
@ -836,6 +839,15 @@ class ANDROIDAPP(Notifier):
'select_options': devices 'select_options': devices
}) })
config_option.append({
'label': 'Priority',
'value': self.config['priority'],
'name': 'androidapp_priority',
'description': 'Set the notification priority.',
'input_type': 'select',
'select_options': {1: 'Minimum', 2: 'Low', 3: 'Normal', 4: 'High'}
})
return config_option return config_option
@ -1928,7 +1940,7 @@ class NMA(Notifier):
{'label': 'Priority', {'label': 'Priority',
'value': self.config['priority'], 'value': self.config['priority'],
'name': 'nma_priority', 'name': 'nma_priority',
'description': 'Set the priority.', 'description': 'Set the notification priority.',
'input_type': 'select', 'input_type': 'select',
'select_options': {-2: -2, -1: -1, 0: 0, 1: 1, 2: 2} 'select_options': {-2: -2, -1: -1, 0: 0, 1: 1, 2: 2}
} }
@ -2189,7 +2201,7 @@ class PROWL(Notifier):
{'label': 'Priority', {'label': 'Priority',
'value': self.config['priority'], 'value': self.config['priority'],
'name': 'prowl_priority', 'name': 'prowl_priority',
'description': 'Set the priority.', 'description': 'Set the notification priority.',
'input_type': 'select', 'input_type': 'select',
'select_options': {-2: -2, -1: -1, 0: 0, 1: 1, 2: 2} 'select_options': {-2: -2, -1: -1, 0: 0, 1: 1, 2: 2}
} }
@ -2439,7 +2451,7 @@ class PUSHOVER(Notifier):
{'label': 'Priority', {'label': 'Priority',
'value': self.config['priority'], 'value': self.config['priority'],
'name': 'pushover_priority', 'name': 'pushover_priority',
'description': 'Set the priority.', 'description': 'Set the notification priority.',
'input_type': 'select', 'input_type': 'select',
'select_options': {-2: -2, -1: -1, 0: 0, 1: 1, 2: 2} 'select_options': {-2: -2, -1: -1, 0: 0, 1: 1, 2: 2}
}, },