Log test notifications

This commit is contained in:
JonnyWong16 2017-04-19 19:43:22 -07:00
parent 006e7c214d
commit f2f28f48cb
2 changed files with 19 additions and 12 deletions

View file

@ -181,16 +181,21 @@ def notify(notifier_id=None, notify_action=None, stream_data=None, timeline_data
if not notifier_config: if not notifier_config:
return return
# Get the subject and body strings if notify_action == 'test':
subject_string = notifier_config['notify_text'][notify_action]['subject'] subject = kwargs.pop('subject', 'PlexPy')
body_string = notifier_config['notify_text'][notify_action]['body'] 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 # Format the subject and body strings
subject, body, script_args = build_notify_text(subject=subject_string, subject, body, script_args = build_notify_text(subject=subject_string,
body=body_string, body=body_string,
notify_action=notify_action, notify_action=notify_action,
parameters=parameters, parameters=parameters,
agent_id=notifier_config['agent_id']) agent_id=notifier_config['agent_id'])
# Set the notification state in the db # Set the notification state in the db
notification_id = set_notify_state(session=stream_data or timeline_data, notification_id = set_notify_state(session=stream_data or timeline_data,
@ -207,10 +212,12 @@ def notify(notifier_id=None, notify_action=None, stream_data=None, timeline_data
script_args=script_args, script_args=script_args,
notify_action=notify_action, notify_action=notify_action,
notification_id=notification_id, notification_id=notification_id,
parameters=parameters) parameters=parameters,
**kwargs)
if success: if success:
set_notify_success(notification_id) set_notify_success(notification_id)
return True
def get_notify_state(session): def get_notify_state(session):

View file

@ -3087,10 +3087,10 @@ class WebInterface(object):
if notifier: if notifier:
logger.debug(u"Sending %s%s notification." % (test, notifier['agent_name'])) logger.debug(u"Sending %s%s notification." % (test, notifier['agent_name']))
if notifiers.send_notification(notifier_id=notifier_id, if notification_handler.notify(notifier_id=notifier_id,
notify_action=notify_action,
subject=subject, subject=subject,
body=body, body=body,
notify_action=notify_action,
**kwargs): **kwargs):
return "Notification sent." return "Notification sent."
else: else: