Skip to content

Commit

Permalink
If there is no transactional id, skip it (#2047)
Browse files Browse the repository at this point in the history
  • Loading branch information
acasajus authored Mar 4, 2024
1 parent 7642352 commit 565f6dc
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions email_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1892,23 +1892,24 @@ def handle_transactional_bounce(
):
LOG.d("handle transactional bounce sent to %s", rcpt_to)

# parse the TransactionalEmail
transactional_id = transactional_id or parse_id_from_bounce(rcpt_to)
transactional = TransactionalEmail.get(transactional_id)

# a transaction might have been deleted in delete_logs()
if transactional:
LOG.i("Create bounce for %s", transactional.email)
bounce_info = get_mailbox_bounce_info(msg)
if bounce_info:
Bounce.create(
email=transactional.email,
info=bounce_info.as_bytes().decode(),
commit=True,
)
else:
LOG.w("cannot get bounce info, debug at %s", save_email_for_debugging(msg))
Bounce.create(email=transactional.email, commit=True)
if not transactional:
LOG.i(
f"No transactional record for {envelope.mail_from} -> {envelope.rcpt_tos}"
)
return
LOG.i("Create bounce for %s", transactional.email)
bounce_info = get_mailbox_bounce_info(msg)
if bounce_info:
Bounce.create(
email=transactional.email,
info=bounce_info.as_bytes().decode(),
commit=True,
)
else:
LOG.w("cannot get bounce info, debug at %s", save_email_for_debugging(msg))
Bounce.create(email=transactional.email, commit=True)


def handle_bounce(envelope, email_log: EmailLog, msg: Message) -> str:
Expand Down

0 comments on commit 565f6dc

Please sign in to comment.