mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-12 16:22:57 -07:00
Add custom headers to Webhook notification agent
This commit is contained in:
parent
f5794a5bae
commit
ddbd486500
3 changed files with 71 additions and 27 deletions
|
@ -3613,19 +3613,29 @@ class WEBHOOK(Notifier):
|
|||
}
|
||||
|
||||
def agent_notify(self, subject='', body='', action='', **kwargs):
|
||||
if subject:
|
||||
try:
|
||||
webhook_headers = json.loads(subject)
|
||||
except ValueError as e:
|
||||
logger.error(u"Tautulli Notifiers :: Invalid {name} json header data: {e}".format(name=self.NAME, e=e))
|
||||
return False
|
||||
else:
|
||||
webhook_headers = None
|
||||
|
||||
if body:
|
||||
try:
|
||||
webhook_data = json.loads(body)
|
||||
webhook_body = json.loads(body)
|
||||
except ValueError as e:
|
||||
logger.error(u"Tautulli Notifiers :: Invalid {name} json data: {e}".format(name=self.NAME, e=e))
|
||||
logger.error(u"Tautulli Notifiers :: Invalid {name} json body data: {e}".format(name=self.NAME, e=e))
|
||||
return False
|
||||
|
||||
else:
|
||||
webhook_data = None
|
||||
webhook_body = None
|
||||
|
||||
headers = {'Content-type': 'application/json'}
|
||||
if webhook_headers:
|
||||
headers.update(webhook_headers)
|
||||
|
||||
return self.make_request(self.config['hook'], method=self.config['method'], headers=headers, json=webhook_data)
|
||||
return self.make_request(self.config['hook'], method=self.config['method'], headers=headers, json=webhook_body)
|
||||
|
||||
def _return_config_options(self):
|
||||
config_option = [{'label': 'Webhook URL',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue