Manual merge v2 notifications encryption

This commit is contained in:
JonnyWong16 2017-04-19 19:58:39 -07:00
commit 59f12c71a9
11 changed files with 11616 additions and 84 deletions

View file

@ -190,32 +190,43 @@ def notify(notifier_id=None, notify_action=None, stream_data=None, timeline_data
if not notifier_config:
return
# Get the subject and body strings
subject_string = notifier_config['notify_text'][notify_action]['subject']
body_string = notifier_config['notify_text'][notify_action]['body']
if notify_action == 'test':
subject = kwargs.pop('subject', 'PlexPy')
body = kwargs.pop('body', 'Test Notification')
script_args = kwargs.pop('script_args', [])
else:
# Get the subject and body strings
subject_string = notifier_config['notify_text'][notify_action]['subject']
body_string = notifier_config['notify_text'][notify_action]['body']
# Format the subject and body strings
subject, body, script_args = build_notify_text(subject=subject_string,
body=body_string,
notify_action=notify_action,
parameters=parameters,
agent_id=notifier_config['agent_id'])
# Send the notification
notifiers.send_notification(notifier_id=notifier_config['id'],
subject=subject,
body=body,
script_args=script_args,
notify_action=notify_action,
parameters=parameters)
# Format the subject and body strings
subject, body, script_args = build_notify_text(subject=subject_string,
body=body_string,
notify_action=notify_action,
parameters=parameters,
agent_id=notifier_config['agent_id'])
# Set the notification state in the db
set_notify_state(session=stream_data or timeline_data,
notify_action=notify_action,
notifier=notifier_config,
subject=subject,
body=body,
script_args=script_args)
notification_id = set_notify_state(session=stream_data or timeline_data,
notify_action=notify_action,
notifier=notifier_config,
subject=subject,
body=body,
script_args=script_args)
# Send the notification
success = notifiers.send_notification(notifier_id=notifier_config['id'],
subject=subject,
body=body,
script_args=script_args,
notify_action=notify_action,
notification_id=notification_id,
parameters=parameters,
**kwargs)
if success:
set_notify_success(notification_id)
return True
def get_notify_state(session):
@ -263,10 +274,19 @@ def set_notify_state(notify_action, notifier, subject, body, script_args, sessio
'script_args': script_args}
monitor_db.upsert(table_name='notify_log', key_dict=keys, value_dict=values)
return monitor_db.last_insert_id()
else:
logger.error(u"PlexPy NotificationHandler :: Unable to set notify state.")
def set_notify_success(notification_id):
keys = {'id': notification_id}
values = {'success': 1}
monitor_db = database.MonitorDatabase()
monitor_db.upsert(table_name='notify_log', key_dict=keys, value_dict=values)
def build_media_notify_params(notify_action=None, session=None, timeline=None, **kwargs):
# Get time formats
date_format = plexpy.CONFIG.DATE_FORMAT.replace('Do','')