Format Webhook data strings only
This commit is contained in:
@@ -1128,10 +1128,7 @@ def traverse_map(obj, func):
|
||||
for k, v in obj.iteritems():
|
||||
new_obj[traverse_map(k, func)] = traverse_map(v, func)
|
||||
|
||||
elif isinstance(obj, basestring):
|
||||
else:
|
||||
new_obj = func(obj)
|
||||
|
||||
else:
|
||||
new_obj = obj
|
||||
|
||||
return new_obj
|
||||
|
@@ -1058,14 +1058,21 @@ def build_notify_text(subject='', body='', notify_action=None, parameters=None,
|
||||
script_args = []
|
||||
|
||||
elif agent_id == 25:
|
||||
if body:
|
||||
try:
|
||||
body = json.loads(body)
|
||||
except ValueError as e:
|
||||
logger.error(u"Tautulli NotificationHandler :: Unable to parse custom webhook json data: %s. Using fallback." % e)
|
||||
body = ''
|
||||
|
||||
if body:
|
||||
def str_format(s):
|
||||
if isinstance(s, basestring):
|
||||
return custom_formatter.format(s, **parameters).decode(plexpy.SYS_ENCODING, 'ignore')
|
||||
return s
|
||||
|
||||
try:
|
||||
body = json.dumps(helpers.traverse_map(body,
|
||||
lambda x: custom_formatter.format(x, **parameters).decode(plexpy.SYS_ENCODING, 'ignore')))
|
||||
body = json.dumps(helpers.traverse_map(body, str_format))
|
||||
except LookupError as e:
|
||||
logger.error(u"Tautulli NotificationHandler :: Unable to parse parameter %s in webhook data. Using fallback." % e)
|
||||
body = ''
|
||||
|
Reference in New Issue
Block a user