Skip to content

Commit

Permalink
Merge pull request #6 from ebmdatalab/delayed-bounce
Browse files Browse the repository at this point in the history
Skip delayed bounce events
  • Loading branch information
ccunningham101 committed Jan 9, 2024
2 parents f2d9d0b + e51c43d commit f7f8b8c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion retractions/management/commands/retrieve_mailgun_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ def handle(self, *args, **options):

# Loop through them
for i in list(items):
message_id = i["message"]["headers"]["message-id"]
event = i["event"]
try:
message_id = i["message"]["headers"]["message-id"]
except KeyError:
logging.warning(f"{i['event']} has no message id, skipped")
continue
when = datetime.datetime.utcfromtimestamp(i["timestamp"])
url = None
if event == "clicked":
Expand Down Expand Up @@ -109,6 +113,8 @@ def handle(self, *args, **options):
or when > mail_sent.clicked_other
):
mail_sent.clicked_other = when
elif event == "failed":
continue
else:
logging.warning("Unknown event '%s'" % event)

Expand Down

0 comments on commit f7f8b8c

Please sign in to comment.