Skip to content

Commit d8e2b9f

Browse files
committed
feat: Don't mark messages as seen on IMAP if bcc_self=0 or bot=1
bcc_self=0 means that the user disabled it or it's a chatmail setup with the only device and w/o backups. If a backup is made someday, old messages not marked as IMAP-seen aren't a problem and new ones are marked as IMAP-seen. For bots, particularly multi-device ones (which are a rare case), probably no sane logic can be built on the "seen" message status. Moreover, if the user has additionally a bot that reads incoming messages, it doesn't mean that the user doesn't want to read them too. Also don't mark a message as IMAP-seen just if it already exists on the device as this doesn't mean that it exists on another device. Also don't mark MDNs and DSNs as IMAP-seen. Marking MDNs as seen is useless, they shouldn't be displayed by any MUA. Auto-marking DSNs as seen should be avoided because the user may want to see them in another MUA.
1 parent 7ee6f2c commit d8e2b9f

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

deltachat-rpc-client/tests/test_multidevice.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ def test_one_account_send_bcc_setting(acfactory, log, direct_imap):
4444

4545
# now make sure we are sending message to ourselves too
4646
assert self_addr in ev.msg
47-
assert self_addr in ev.msg
4847

4948
# BCC-self messages are marked as seen by the sender device.
5049
while True:

src/imap.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2248,11 +2248,16 @@ pub(crate) async fn prefetch_should_download(
22482248
message_id: &str,
22492249
mut flags: impl Iterator<Item = Flag<'_>>,
22502250
) -> Result<bool> {
2251-
if message::rfc724_mid_exists(context, message_id)
2252-
.await?
2253-
.is_some()
2251+
if let Some((.., seen)) = message::rfc724_mid_exists_ex(
2252+
context,
2253+
message_id,
2254+
"state>=16", // `InSeen`
2255+
)
2256+
.await?
22542257
{
2255-
markseen_on_imap_table(context, message_id).await?;
2258+
if seen {
2259+
markseen_on_imap_table(context, message_id).await?;
2260+
}
22562261
return Ok(false);
22572262
}
22582263

@@ -2397,6 +2402,11 @@ async fn mark_seen_by_uid(
23972402
/// Schedule marking the message as Seen on IMAP by adding all known IMAP messages corresponding to
23982403
/// the given Message-ID to `imap_markseen` table.
23992404
pub(crate) async fn markseen_on_imap_table(context: &Context, message_id: &str) -> Result<()> {
2405+
if !context.get_config_bool(Config::BccSelf).await?
2406+
|| context.get_config_bool(Config::Bot).await?
2407+
{
2408+
return Ok(());
2409+
}
24002410
context
24012411
.sql
24022412
.execute(

src/receive_imf.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -993,11 +993,6 @@ pub(crate) async fn receive_imf_inner(
993993
)
994994
.await?;
995995
}
996-
if target.is_none() && !mime_parser.mdn_reports.is_empty() && mime_parser.has_chat_version()
997-
{
998-
// This is a Delta Chat MDN. Mark as read.
999-
markseen_on_imap_table(context, rfc724_mid_orig).await?;
1000-
}
1001996
}
1002997

1003998
if mime_parser.is_call() {
@@ -1145,8 +1140,9 @@ async fn decide_chat_assignment(
11451140
info!(context, "Message is an MDN (TRASH).");
11461141
true
11471142
} else if mime_parser.delivery_report.is_some() {
1143+
// Auto-marking DSNs as IMAP-seen should be avoided because the user may want to see them in
1144+
// another MUA.
11481145
info!(context, "Message is a DSN (TRASH).");
1149-
markseen_on_imap_table(context, rfc724_mid).await.ok();
11501146
true
11511147
} else if mime_parser.get_header(HeaderDef::ChatEdit).is_some()
11521148
|| mime_parser.get_header(HeaderDef::ChatDelete).is_some()

0 commit comments

Comments
 (0)