[FIX] l10n_it_edi: imap seen flag more compatible

For an imap "PEC server" we will fetch mail and set \Seen flag according to
current value.

But the way imaplib was used seem to possibly cause an issue on some
particular mail providers.

Mailing RFC* gives example of adding flags with parenthesis around flag:

eg. "A003 STORE 2:4 +FLAGS (\Deleted)"

but we are sending these command wihtout parenthesis (which seems to be
working, but apparently not for some providers).

To fix this issue, we change how we use the API to do the same thing
than in fetchmail module that is a lot more battle tested (and from logs
is sending flags in parenthesis).

* https://datatracker.ietf.org/doc/html/rfc3501#section-6.4.6

fixing #89305
fixing #81443
opw-2714596

closes odoo/odoo#89379

X-original-commit: 7dd5437a65bd43a91d6ae7e2fb4f11f2f0b1476b
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
This commit is contained in:
Nicolas Lempereur
2022-04-22 16:59:53 +02:00
parent 7c4f200b8e
commit 2130fb38ac
+2 -2
View File
@@ -84,9 +84,9 @@ class FetchmailServer(models.Model):
# To leave the mail in the state in which they were.
if "Seen" not in data[1].decode("utf-8"):
imap_server.uid('STORE', uid, '+FLAGS', '\\Seen')
imap_server.store(uid, '+FLAGS', '\\Seen')
else:
imap_server.uid('STORE', uid, '-FLAGS', '\\Seen')
imap_server.store(uid, '-FLAGS', '\\Seen')
# See details in message_process() in mail_thread.py
if isinstance(message, xmlrpclib.Binary):