From edabf208bc15fbf7cbead983e02cc59258f6a59f Mon Sep 17 00:00:00 2001 From: Stefan Date: Wed, 17 Aug 2022 10:40:51 +0200 Subject: [PATCH] Handle tags for gmail email accounts like mentioned here: https://github.com/ikvk/imap_tools/issues/174 --- src/paperless_mail/mail.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/paperless_mail/mail.py b/src/paperless_mail/mail.py index e1357d958..e7991e25b 100644 --- a/src/paperless_mail/mail.py +++ b/src/paperless_mail/mail.py @@ -1,4 +1,5 @@ import os +import re import tempfile from datetime import date from datetime import timedelta @@ -70,7 +71,11 @@ class TagMailAction(BaseMailAction): return {"no_keyword": self.keyword} def post_consume(self, M: MailBox, message_uids, parameter): - M.flag(message_uids, [self.keyword], True) + if re.search(r"gmail\.com$|googlemail\.com$", M._host): + for uid in message_uids: + M.client.uid("STORE", uid, 'X-GM-LABELS', self.keyword) + else: + M.flag(message_uids, [self.keyword], True) def get_rule_action(rule):