From c3a5e3ac0df7875e03a02cefe516636c7fa27b04 Mon Sep 17 00:00:00 2001 From: Hocuri Date: Mon, 19 Jan 2026 12:39:06 +0100 Subject: [PATCH] feat: In teamprofiles, don't mark chat as read on outgoing message (#7717) Fix https://github.com/chatmail/core/issues/7704 --- deltachat-rpc-client/tests/test_something.py | 41 ++++++++++++++++++++ src/chat.rs | 4 ++ src/imap.rs | 2 - 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/deltachat-rpc-client/tests/test_something.py b/deltachat-rpc-client/tests/test_something.py index 8758dd593..a80bb13b9 100644 --- a/deltachat-rpc-client/tests/test_something.py +++ b/deltachat-rpc-client/tests/test_something.py @@ -911,6 +911,47 @@ def test_markseen_contact_request(acfactory): assert message2.get_snapshot().state == MessageState.IN_SEEN +@pytest.mark.parametrize("team_profile", [True, False]) +def test_no_markseen_in_team_profile(team_profile, acfactory): + """ + Test that seen status is synchronized iff `team_profile` isn't set. + """ + alice, bob = acfactory.get_online_accounts(2) + if team_profile: + bob.set_config("team_profile", "1") + + # Bob sets up a second device. + bob2 = bob.clone() + bob2.start_io() + + alice_chat_bob = alice.create_chat(bob) + bob_chat_alice = bob.create_chat(alice) + bob2.create_chat(alice) + alice_chat_bob.send_text("Hello Bob!") + + message = bob.wait_for_incoming_msg() + message2 = bob2.wait_for_incoming_msg() + assert message2.get_snapshot().state == MessageState.IN_FRESH + + message.mark_seen() + + # Send a message and wait until it arrives + # in order to wait until Bob2 gets the markseen message. + # This also tests that outgoing messages + # don't mark preceeding messages as seen in team profiles. + bob_chat_alice.send_text("Outgoing message") + while True: + outgoing = bob2.wait_for_msg(EventType.MSGS_CHANGED) + if outgoing.id != 0: + break + assert outgoing.get_snapshot().text == "Outgoing message" + + if team_profile: + assert message2.get_snapshot().state == MessageState.IN_FRESH + else: + assert message2.get_snapshot().state == MessageState.IN_SEEN + + def test_read_receipt(acfactory): """ Test sending a read receipt and ensure it is attributed to the correct contact. diff --git a/src/chat.rs b/src/chat.rs index 53dc0abf8..da07f6c08 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -3305,6 +3305,10 @@ pub(crate) async fn mark_old_messages_as_noticed( context: &Context, mut msgs: Vec, ) -> Result<()> { + if context.get_config_bool(Config::TeamProfile).await? { + return Ok(()); + } + msgs.retain(|m| m.state.is_outgoing()); if msgs.is_empty() { return Ok(()); diff --git a/src/imap.rs b/src/imap.rs index 4b6a49af7..dfc3cf88d 100644 --- a/src/imap.rs +++ b/src/imap.rs @@ -1140,7 +1140,6 @@ impl Session { /// Stores pending `\Seen` flags for messages in `imap_markseen` table. pub(crate) async fn store_seen_flags_on_imap(&mut self, context: &Context) -> Result<()> { if context.get_config_bool(Config::TeamProfile).await? { - info!(context, "Team profile, skipping seen flag synchronization."); return Ok(()); } @@ -1216,7 +1215,6 @@ impl Session { } if context.get_config_bool(Config::TeamProfile).await? { - info!(context, "Team profile, skipping seen flag synchronization."); return Ok(()); }