From 8f6550f992f1c17ee2966c6fd0f929352ab45e32 Mon Sep 17 00:00:00 2001 From: Son NK <> Date: Tue, 27 Oct 2020 10:40:44 +0100 Subject: [PATCH] update contact.mail_from and contact.from_header if needed --- email_handler.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/email_handler.py b/email_handler.py index 45ad5ac2..2ce22576 100644 --- a/email_handler.py +++ b/email_handler.py @@ -178,6 +178,26 @@ def get_or_create_contact( ) contact.name = contact_name db.session.commit() + + if contact.mail_from != mail_from: + LOG.d( + "Update contact %s mail_from %s to %s", + contact, + contact.mail_from, + mail_from, + ) + contact.mail_from = mail_from + db.session.commit() + + if contact.from_header != contact_from_header: + LOG.d( + "Update contact %s from_header %s to %s", + contact, + contact.from_header, + contact_from_header, + ) + contact.from_header = contact_from_header + db.session.commit() else: LOG.debug( "create contact for alias %s and contact %s",