fix: fetch with BODY.PEEK[] so a fetch never sets \Seen
RFC822 / BODY[] on a SELECTed mailbox set \Seen as a side effect (RFC 3501). with the UNSEEN query, one flow fetching and rejecting a message hid it from another flow on the same mailbox. only mark_seen() flags a message now; the icloud param is kept and is a no-op. Signed-off-by: disqualifier <dev@disqualifier.me>
This commit is contained in:
1 parent
e95a624ad3
commit
7d1f91afba
1 file changed
+8
-2
@@ -229,10 +229,16 @@ class IMAPClient:
|
||||
return sorted(set(ids), reverse=True)
|
||||
|
||||
async def fetch(self, email_id: int, *, icloud: bool = False) -> Optional[email.message.Message]:
|
||||
"""fetch and parse a full message by id"""
|
||||
"""fetch and parse a full message by id without setting \\Seen
|
||||
|
||||
uses BODY.PEEK[]: RFC822 / BODY[] on a SELECTed mailbox set \\Seen as a side effect
|
||||
(RFC 3501), so a fetched-then-rejected message would vanish from every later UNSEEN
|
||||
search. only mark_seen() flags a message. `icloud` is kept for compatibility and is
|
||||
now a no-op (BODY.PEEK[] already works there)
|
||||
"""
|
||||
if not await self.ensure_connection():
|
||||
return None
|
||||
part = "(BODY[])" if icloud else "(RFC822)"
|
||||
part = "(BODY.PEEK[])"
|
||||
try:
|
||||
if self.use_uid:
|
||||
result, data = await self._mail.uid("fetch", str(email_id), part)
|
||||
|
||||
Reference in new issue
Block a user