From 93503d4cd3d55b029c9f664123a258e9cda99db9 Mon Sep 17 00:00:00 2001 From: Son NK <> Date: Fri, 11 Dec 2020 11:03:52 +0100 Subject: [PATCH] Do not rely on revert to delete EmailLog object when pgp fails --- email_handler.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/email_handler.py b/email_handler.py index 041d0306..25221c97 100644 --- a/email_handler.py +++ b/email_handler.py @@ -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