mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-10 07:22:37 -07:00
Format Webhook data strings only
This commit is contained in:
parent
4648e3df5f
commit
5736e12bc3
2 changed files with 21 additions and 17 deletions
|
@ -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,20 +1058,27 @@ def build_notify_text(subject='', body='', notify_action=None, parameters=None,
|
|||
script_args = []
|
||||
|
||||
elif agent_id == 25:
|
||||
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)
|
||||
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 = ''
|
||||
|
||||
try:
|
||||
body = json.dumps(helpers.traverse_map(body,
|
||||
lambda x: custom_formatter.format(x, **parameters).decode(plexpy.SYS_ENCODING, 'ignore')))
|
||||
except LookupError as e:
|
||||
logger.error(u"Tautulli NotificationHandler :: Unable to parse parameter %s in webhook data. Using fallback." % e)
|
||||
body = ''
|
||||
except Exception as e:
|
||||
logger.error(u"Tautulli NotificationHandler :: Unable to parse custom webhook 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, str_format))
|
||||
except LookupError as e:
|
||||
logger.error(u"Tautulli NotificationHandler :: Unable to parse parameter %s in webhook data. Using fallback." % e)
|
||||
body = ''
|
||||
except Exception as e:
|
||||
logger.error(u"Tautulli NotificationHandler :: Unable to parse custom webhook data: %s. Using fallback." % e)
|
||||
body = ''
|
||||
|
||||
else:
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue