Do not rely on revert to delete EmailLog object when pgp fails

This commit is contained in:
Son NK 2020-12-11 11:03:52 +01:00
parent f03bde1d8d
commit 93503d4cd3
1 changed files with 3 additions and 2 deletions

View File

@ -841,6 +841,7 @@ def handle_reply(envelope, msg: Message, rcpt_to: str) -> (bool, str):
is_reply=True,
user_id=contact.user_id,
mailbox_id=mailbox.id,
commit=True
)
# Spam check
@ -909,11 +910,11 @@ def handle_reply(envelope, msg: Message, rcpt_to: str) -> (bool, str):
"Cannot encrypt message %s -> %s. %s %s", alias, contact, mailbox, user
)
# to not save the email_log
db.session.rollback()
EmailLog.delete(email_log.id)
db.session.commit()
# return 421 so the client can retry later
return False, "421 SL E13 Retry later"
# save the email_log to DB
db.session.commit()
# make the email comes from alias