From ce32799f87dae0a63a902987ee34677c6431fc5e Mon Sep 17 00:00:00 2001 From: iequidoo Date: Tue, 16 Sep 2025 03:49:11 -0300 Subject: [PATCH] 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. --- deltachat-rpc-client/tests/test_multidevice.py | 1 - python/tests/test_1_online.py | 18 ++++++++++++------ src/imap.rs | 5 +++++ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/deltachat-rpc-client/tests/test_multidevice.py b/deltachat-rpc-client/tests/test_multidevice.py index 008ed4657..4b5ee31f4 100644 --- a/deltachat-rpc-client/tests/test_multidevice.py +++ b/deltachat-rpc-client/tests/test_multidevice.py @@ -44,7 +44,6 @@ def test_one_account_send_bcc_setting(acfactory, log, direct_imap): # now make sure we are sending message to ourselves too assert self_addr in ev.msg - assert self_addr in ev.msg # BCC-self messages are marked as seen by the sender device. while True: diff --git a/python/tests/test_1_online.py b/python/tests/test_1_online.py index c8526e68d..9c594f275 100644 --- a/python/tests/test_1_online.py +++ b/python/tests/test_1_online.py @@ -162,6 +162,7 @@ def test_html_message(acfactory, lp): def test_webxdc_message(acfactory, data, lp): ac1, ac2 = acfactory.get_online_accounts(2) + ac2.set_config("bcc_self", "1") chat = acfactory.get_accepted_chat(ac1, ac2) lp.sec("ac1: prepare and send text message to ac2") @@ -512,6 +513,8 @@ def test_send_and_receive_message_markseen(acfactory, lp): # make DC's life harder wrt to encodings ac1.set_config("displayname", "รค name") + ac2.set_config("bcc_self", "1") + # clear any fresh device messages ac1.get_device_chat().mark_noticed() ac2.get_device_chat().mark_noticed() @@ -587,7 +590,7 @@ def test_send_and_receive_message_markseen(acfactory, lp): def test_moved_markseen(acfactory): """Test that message already moved to DeltaChat folder is marked as seen.""" ac1 = acfactory.new_online_configuring_account() - ac2 = acfactory.new_online_configuring_account(mvbox_move=True) + ac2 = acfactory.new_online_configuring_account(mvbox_move=True, bcc_self=True) acfactory.bring_accounts_online() ac2.stop_io() @@ -658,10 +661,14 @@ def test_markseen_message_and_mdn(acfactory, mvbox_move): ac1 = acfactory.new_online_configuring_account(mvbox_move=mvbox_move) ac2 = acfactory.new_online_configuring_account(mvbox_move=mvbox_move) acfactory.bring_accounts_online() - # Do not send BCC to self, we only want to test MDN on ac1. - ac1.set_config("bcc_self", "0") + ac2.set_config("bcc_self", "1") + ac2.stop_io() acfactory.get_accepted_chat(ac1, ac2).send_text("hi") + # We only want to test MDN on ac1, so set "bcc_self" after sending. + ac1.set_config("bcc_self", "1") + + ac2.start_io() msg = ac2._evtracker.wait_next_incoming_message() ac2.mark_seen_messages([msg]) @@ -715,9 +722,8 @@ def test_mdn_asymmetric(acfactory, lp): chat = ac1.create_chat(ac2) ac2.create_chat(ac1) - # make sure mdns are enabled (usually enabled by default already) - ac1.set_config("mdns_enabled", "1") - ac2.set_config("mdns_enabled", "1") + ac1.set_config("bcc_self", "1") + ac2.set_config("bcc_self", "1") lp.sec("sending text message from ac1 to ac2") msg_out = chat.send_text("message1") diff --git a/src/imap.rs b/src/imap.rs index ea6d90736..d72eee3eb 100644 --- a/src/imap.rs +++ b/src/imap.rs @@ -2397,6 +2397,11 @@ async fn mark_seen_by_uid( /// Schedule marking the message as Seen on IMAP by adding all known IMAP messages corresponding to /// the given Message-ID to `imap_markseen` table. pub(crate) async fn markseen_on_imap_table(context: &Context, message_id: &str) -> Result<()> { + if !context.get_config_bool(Config::BccSelf).await? + || context.get_config_bool(Config::Bot).await? + { + return Ok(()); + } context .sql .execute(