handle case cannot parse mailbox_id

This commit is contained in:
Son NK 2020-08-16 18:55:14 +02:00
parent a3a99ac3f4
commit 6835c5b69d
1 changed files with 17 additions and 12 deletions

View File

@ -874,8 +874,13 @@ def handle_bounce(contact: Contact, alias: Alias, msg: Message, user: User):
file_path, BytesIO(orig_msg.as_bytes()), random_name
)
# <<< END Store the bounced email >>>
try:
mailbox_id = int(orig_msg[_MAILBOX_ID_HEADER])
except TypeError:
LOG.warning("cannot parse mailbox from %s", orig_msg[_MAILBOX_ID_HEADER])
# use the alias default mailbox
mailbox = alias.mailbox
else:
mailbox = Mailbox.get(mailbox_id)
if not mailbox or mailbox.user_id != user.id:
LOG.exception(