pull/541/head
meisnate12 3 years ago
parent 364f261b4c
commit e0c42c272a

@ -19,6 +19,7 @@ class Webhooks:
logger.debug("") logger.debug("")
logger.debug(f"JSON: {json}") logger.debug(f"JSON: {json}")
for webhook in list(set(webhooks)): for webhook in list(set(webhooks)):
response = None
if self.config.trace_mode: if self.config.trace_mode:
logger.debug(f"Webhook: {webhook}") logger.debug(f"Webhook: {webhook}")
if webhook == "notifiarr": if webhook == "notifiarr":
@ -30,17 +31,18 @@ class Webhooks:
break break
else: else:
response = self.config.post(webhook, json=json) response = self.config.post(webhook, json=json)
try: if response:
response_json = response.json() try:
if self.config.trace_mode: response_json = response.json()
logger.debug(f"Response: {response_json}") if self.config.trace_mode:
if "result" in response_json and response_json["result"] == "error" and "details" in response_json and "response" in response_json["details"]: logger.debug(f"Response: {response_json}")
raise Failed(f"Notifiarr Error: {response_json['details']['response']}") if "result" in response_json and response_json["result"] == "error" and "details" in response_json and "response" in response_json["details"]:
if response.status_code >= 400 or ("result" in response_json and response_json["result"] == "error"): raise Failed(f"Notifiarr Error: {response_json['details']['response']}")
raise Failed(f"({response.status_code} [{response.reason}]) {response_json}") if response.status_code >= 400 or ("result" in response_json and response_json["result"] == "error"):
except JSONDecodeError: raise Failed(f"({response.status_code} [{response.reason}]) {response_json}")
if response.status_code >= 400: except JSONDecodeError:
raise Failed(f"({response.status_code} [{response.reason}])") if response.status_code >= 400:
raise Failed(f"({response.status_code} [{response.reason}])")
def start_time_hooks(self, start_time): def start_time_hooks(self, start_time):
if self.run_start_webhooks: if self.run_start_webhooks:

Loading…
Cancel
Save