From 0925c900478da96478866118a702b3d8ed289e3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6pp?= Date: Wed, 2 Mar 2022 15:07:53 +0100 Subject: [PATCH] Switched to `flag()` Newer versions of imap_tools moved away from `seen()` in favour of `flag()` and deprecated the former. This fixes https://github.com/jonaswinkler/paperless-ng/issues/1672 I also remove the mocked `seen()` function and updated the `flag()` mock --- src/paperless_mail/mail.py | 2 +- src/paperless_mail/tests/test_mail.py | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/paperless_mail/mail.py b/src/paperless_mail/mail.py index bc35f0e0d..0e9294927 100644 --- a/src/paperless_mail/mail.py +++ b/src/paperless_mail/mail.py @@ -44,7 +44,7 @@ class MarkReadMailAction(BaseMailAction): return {"seen": False} def post_consume(self, M, message_uids, parameter): - M.seen(message_uids, True) + M.flag(message_uids, [MailMessageFlags.SEEN], True) class MoveMailAction(BaseMailAction): diff --git a/src/paperless_mail/tests/test_mail.py b/src/paperless_mail/tests/test_mail.py index b1f6ef807..10aa431db 100644 --- a/src/paperless_mail/tests/test_mail.py +++ b/src/paperless_mail/tests/test_mail.py @@ -68,11 +68,6 @@ class BogusMailBox(ContextManager): return list(msg) - def seen(self, uid_list, seen_val): - for message in self.messages: - if message.uid in uid_list: - message.seen = seen_val - def delete(self, uid_list): self.messages = list(filter(lambda m: m.uid not in uid_list, self.messages)) @@ -82,6 +77,8 @@ class BogusMailBox(ContextManager): for flag in flag_set: if flag == MailMessageFlags.FLAGGED: message.flagged = value + if flag == MailMessageFlags.SEEN: + message.seen = value def move(self, uid_list, folder): if folder == "spam":