From 44c2febbe11ad3fc2b57f3660302fbeae67991c8 Mon Sep 17 00:00:00 2001 From: link2xt Date: Sun, 13 Sep 2026 21:39:11 +0000 Subject: [PATCH] test(direct_imap): always pass mark_seen=False to fetch() mark_seen=True is the default and translates to fetching BODY of the message. mark_seen=False translates to fetching BODY.PEEK that is described in IETF RFC 3501 as "An alternate form of BODY[
] that does not implicitly set the \Seen flag." It is unexpected unless you know this detail of IMAP protocol already, but this is not going to be fixed in imap_tools: --- deltachat-rpc-client/tests/conftest.py | 2 +- python/src/deltachat/direct_imap.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/deltachat-rpc-client/tests/conftest.py b/deltachat-rpc-client/tests/conftest.py index e7899f7c5..19b106728 100644 --- a/deltachat-rpc-client/tests/conftest.py +++ b/deltachat-rpc-client/tests/conftest.py @@ -171,7 +171,7 @@ class DirectImap: self.conn.append(bytes(msg, encoding="ascii"), folder) def get_uid_by_message_id(self, message_id) -> str: - msgs = [msg.uid for msg in self.conn.fetch(AND(header=Header("MESSAGE-ID", message_id)))] + msgs = [msg.uid for msg in self.conn.fetch(AND(header=Header("MESSAGE-ID", message_id)), mark_seen=False)] if len(msgs) == 0: raise Exception("Did not find message " + message_id + ", maybe you forgot to select the correct folder?") return msgs[0] diff --git a/python/src/deltachat/direct_imap.py b/python/src/deltachat/direct_imap.py index 35491e41b..9a7297363 100644 --- a/python/src/deltachat/direct_imap.py +++ b/python/src/deltachat/direct_imap.py @@ -104,11 +104,11 @@ class DirectImap: def get_all_messages(self) -> List[MailMessage]: assert not self._idling - return list(self.conn.fetch()) + return list(self.conn.fetch(mark_seen=False)) def get_unread_messages(self) -> List[str]: assert not self._idling - return [msg.uid for msg in self.conn.fetch(AND(seen=False))] + return [msg.uid for msg in self.conn.fetch(AND(seen=False), mark_seen=False)] def mark_all_read(self): messages = self.get_unread_messages() @@ -183,7 +183,7 @@ class DirectImap: self.conn.append(bytes(msg, encoding="ascii"), folder) def get_uid_by_message_id(self, message_id) -> str: - msgs = [msg.uid for msg in self.conn.fetch(AND(header=Header("MESSAGE-ID", message_id)))] + msgs = [msg.uid for msg in self.conn.fetch(AND(header=Header("MESSAGE-ID", message_id)), mark_seen=False)] if len(msgs) == 0: raise Exception("Did not find message " + message_id + ", maybe you forgot to select the correct folder?") return msgs[0]