Mailgun: fix webhook error with null delivery-status

Mailgun now sometimes posts `"delivery-status": null` 
in the tracking event payload. Avoid raising an AttributeError
when that occurs.

Fixes #361
This commit is contained in:
David Jean Louis
2024-03-05 22:58:41 +01:00
committed by GitHub
parent a71a0d9af8
commit 5949069321
3 changed files with 28 additions and 4 deletions

View File

@@ -172,12 +172,12 @@ class MailgunTrackingWebhookView(MailgunBaseWebhookView):
try:
delivery_status = event_data["delivery-status"]
except KeyError:
description = None
mta_response = None
else:
# if delivery_status is None, an AttributeError will be raised
description = delivery_status.get("description")
mta_response = delivery_status.get("message")
except (KeyError, AttributeError):
description = None
mta_response = None
if "reason" in event_data:
reject_reason = self.reject_reasons.get(