Merge pull request #250 from bakerboy448/cleanup

simplfy webhook logic & improve logging
This commit is contained in:
bobokun 2023-03-31 19:41:23 -04:00 committed by GitHub
commit 900fc1101b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -48,7 +48,9 @@ class Webhooks:
response = self.config.post(webhook_post, json=json) response = self.config.post(webhook_post, json=json)
if response.status_code < 500: if response.status_code < 500:
return response return response
logger.debug(f"({response.status_code} [{response.reason}]) Retrying in {request_delay} seconds.")
time.sleep(request_delay) time.sleep(request_delay)
logger.debug(f"(Retry {retry_count + 1} of {retry_attempts}.")
retry_count += 1 retry_count += 1
logger.warning(f"({response.status_code} [{response.reason}]) after {retry_attempts} attempts.") logger.warning(f"({response.status_code} [{response.reason}]) after {retry_attempts} attempts.")
@ -64,14 +66,9 @@ class Webhooks:
logger.trace(f"Webhook: {webhook}") logger.trace(f"Webhook: {webhook}")
if webhook is None: if webhook is None:
break break
elif webhook == "notifiarr": elif (webhook == "notifiarr" and self.notifiarr is None) or (webhook == "apprise" and self.apprise is None):
if self.notifiarr is None: logger.warning(f"Webhook attribute set to {webhook} but {webhook} attribute is not configured.")
logger.warning(f"Webhook attribute set to {webhook} but {webhook} attribute is not configured.") break
break
elif webhook == "apprise":
if self.apprise is None:
logger.warning(f"Webhook attribute set to {webhook} but {webhook} attribute is not configured.")
break
response = self.request_and_check(webhook, json) response = self.request_and_check(webhook, json)
if response: if response:
skip = False skip = False
@ -85,7 +82,7 @@ class Webhooks:
and "response" in response_json["details"] and "response" in response_json["details"]
): ):
if "trigger is not enabled" in response_json["details"]["response"]: if "trigger is not enabled" in response_json["details"]["response"]:
logger.debug(f"Notifiarr Warning: {response_json['details']['response']}") logger.info(f"Notifiarr Warning: {response_json['details']['response']}")
skip = True skip = True
else: else:
raise Failed(f"Notifiarr Error: {response_json['details']['response']}") raise Failed(f"Notifiarr Error: {response_json['details']['response']}")