From 1e3a3477820cfc310f3b4538a86be4702b875152 Mon Sep 17 00:00:00 2001 From: samwiseg00 Date: Fri, 5 Oct 2018 23:18:00 -0400 Subject: [PATCH] Populate NULL text fields after a DB update --- plexpy/notifiers.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/plexpy/notifiers.py b/plexpy/notifiers.py index 7768e650..9c484033 100644 --- a/plexpy/notifiers.py +++ b/plexpy/notifiers.py @@ -411,7 +411,9 @@ def get_notify_agents(): return tuple(a['name'] for a in sorted(available_notification_agents(), key=lambda k: k['label'])) -def get_notify_actions(): +def get_notify_actions(return_dict=False): + if return_dict: + return {a.pop('name'): a for a in available_notification_actions()} return tuple(a['name'] for a in available_notification_actions()) @@ -475,15 +477,23 @@ def get_notifier_config(notifier_id=None): logger.error(u"Tautulli Notifiers :: Failed to get notifier config options: %s." % e) return - notify_actions = get_notify_actions() + notify_actions = get_notify_actions(return_dict=True) notifier_actions = {} notifier_text = {} for k in result.keys(): if k in notify_actions: + subject = result.pop(k + '_subject') + body = result.pop(k + '_body') + + if subject is None: + subject = "" if result['agent_name'] in ('scripts', 'webhook') else notify_actions[k]['subject'] + if body is None: + body = "" if result['agent_name'] in ('scripts', 'webhook') else notify_actions[k]['body'] + notifier_actions[k] = helpers.cast_to_int(result.pop(k)) - notifier_text[k] = {'subject': result.pop(k + '_subject'), - 'body': result.pop(k + '_body')} + notifier_text[k] = {'subject': subject, + 'body': body} try: result['custom_conditions'] = json.loads(result['custom_conditions'])