Skip to content

Commit ce32799

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.
1 parent 6d860f7 commit ce32799

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
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:

python/tests/test_1_online.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ def test_html_message(acfactory, lp):
162162

163163
def test_webxdc_message(acfactory, data, lp):
164164
ac1, ac2 = acfactory.get_online_accounts(2)
165+
ac2.set_config("bcc_self", "1")
165166
chat = acfactory.get_accepted_chat(ac1, ac2)
166167

167168
lp.sec("ac1: prepare and send text message to ac2")
@@ -512,6 +513,8 @@ def test_send_and_receive_message_markseen(acfactory, lp):
512513
# make DC's life harder wrt to encodings
513514
ac1.set_config("displayname", "ä name")
514515

516+
ac2.set_config("bcc_self", "1")
517+
515518
# clear any fresh device messages
516519
ac1.get_device_chat().mark_noticed()
517520
ac2.get_device_chat().mark_noticed()
@@ -587,7 +590,7 @@ def test_send_and_receive_message_markseen(acfactory, lp):
587590
def test_moved_markseen(acfactory):
588591
"""Test that message already moved to DeltaChat folder is marked as seen."""
589592
ac1 = acfactory.new_online_configuring_account()
590-
ac2 = acfactory.new_online_configuring_account(mvbox_move=True)
593+
ac2 = acfactory.new_online_configuring_account(mvbox_move=True, bcc_self=True)
591594
acfactory.bring_accounts_online()
592595

593596
ac2.stop_io()
@@ -658,10 +661,14 @@ def test_markseen_message_and_mdn(acfactory, mvbox_move):
658661
ac1 = acfactory.new_online_configuring_account(mvbox_move=mvbox_move)
659662
ac2 = acfactory.new_online_configuring_account(mvbox_move=mvbox_move)
660663
acfactory.bring_accounts_online()
661-
# Do not send BCC to self, we only want to test MDN on ac1.
662-
ac1.set_config("bcc_self", "0")
664+
ac2.set_config("bcc_self", "1")
665+
ac2.stop_io()
663666

664667
acfactory.get_accepted_chat(ac1, ac2).send_text("hi")
668+
# We only want to test MDN on ac1, so set "bcc_self" after sending.
669+
ac1.set_config("bcc_self", "1")
670+
671+
ac2.start_io()
665672
msg = ac2._evtracker.wait_next_incoming_message()
666673

667674
ac2.mark_seen_messages([msg])
@@ -715,9 +722,8 @@ def test_mdn_asymmetric(acfactory, lp):
715722
chat = ac1.create_chat(ac2)
716723
ac2.create_chat(ac1)
717724

718-
# make sure mdns are enabled (usually enabled by default already)
719-
ac1.set_config("mdns_enabled", "1")
720-
ac2.set_config("mdns_enabled", "1")
725+
ac1.set_config("bcc_self", "1")
726+
ac2.set_config("bcc_self", "1")
721727

722728
lp.sec("sending text message from ac1 to ac2")
723729
msg_out = chat.send_text("message1")

src/imap.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2397,6 +2397,11 @@ async fn mark_seen_by_uid(
23972397
/// Schedule marking the message as Seen on IMAP by adding all known IMAP messages corresponding to
23982398
/// the given Message-ID to `imap_markseen` table.
23992399
pub(crate) async fn markseen_on_imap_table(context: &Context, message_id: &str) -> Result<()> {
2400+
if !context.get_config_bool(Config::BccSelf).await?
2401+
|| context.get_config_bool(Config::Bot).await?
2402+
{
2403+
return Ok(());
2404+
}
24002405
context
24012406
.sql
24022407
.execute(

0 commit comments

Comments
 (0)