From 13dafa46b5a5ea36845c8bc379d5dbb9b9721522 Mon Sep 17 00:00:00 2001 From: link2xt Date: Thu, 8 Jan 2026 23:37:56 +0000 Subject: [PATCH] fix: take transport_id into account when marking messages with \Seen flags Otherwise wrong IMAP client corresponding to a different transport may pick up the job to mark the message as seen there, and fail to do it as the message does not exist. It may also mark the wrong message with the correct folder and UID, but wrong IMAP server. --- src/imap.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/imap.rs b/src/imap.rs index 2571a8985..0e20293e9 100644 --- a/src/imap.rs +++ b/src/imap.rs @@ -1143,13 +1143,16 @@ impl Session { return Ok(()); } + let transport_id = self.transport_id(); let rows = context .sql .query_map_vec( "SELECT imap.id, uid, folder FROM imap, imap_markseen - WHERE imap.id = imap_markseen.id AND target = folder + WHERE imap.id = imap_markseen.id + AND imap.transport_id=? + AND target = folder ORDER BY folder, uid", - [], + (transport_id,), |row| { let rowid: i64 = row.get(0)?; let uid: u32 = row.get(1)?;