From da43e24d34e58cd2104eba8630695413ac979bf8 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 | 4 ++-- python/src/deltachat/direct_imap.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/deltachat-rpc-client/tests/conftest.py b/deltachat-rpc-client/tests/conftest.py index 9bf4a1f75e..d73823a54f 100644 --- a/deltachat-rpc-client/tests/conftest.py +++ b/deltachat-rpc-client/tests/conftest.py @@ -171,7 +171,7 @@ def append(self, folder: str, msg: str): 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] @@ -182,7 +182,7 @@ def __init__(self, direct_imap) -> None: self.direct_imap = direct_imap # fetch latest messages before starting idle so that it only # returns messages that arrive anew - self.direct_imap.conn.fetch("1:*") + self.direct_imap.conn.fetch("1:*", mark_seen=False) self.direct_imap.conn.idle.start() def check(self, timeout=None) -> list[bytes]: diff --git a/python/src/deltachat/direct_imap.py b/python/src/deltachat/direct_imap.py index aa3e222e52..e919601af8 100644 --- a/python/src/deltachat/direct_imap.py +++ b/python/src/deltachat/direct_imap.py @@ -104,11 +104,11 @@ def delete(self, uid_list: str, expunge=True): 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 @@ def append(self, folder: str, msg: str): 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]