diff --git a/python/tests/test_account.py b/python/tests/test_account.py index 9c5f72886..4decaec85 100644 --- a/python/tests/test_account.py +++ b/python/tests/test_account.py @@ -970,6 +970,30 @@ class TestOnlineAccount: except queue.Empty: pass # mark_seen_messages() has generated events before it returns + @pytest.mark.parametrize("mvbox_move", [True, False]) + def test_markseen_message_and_mdn(self, acfactory, mvbox_move): + # Please only change this test if you are very sure that it will still catch the issues it catches now. + # We had so many problems with markseen, if in doubt, rather create another test, it can't harm. + ac1 = acfactory.get_online_configuring_account(move=mvbox_move, mvbox=mvbox_move) + ac2 = acfactory.get_online_configuring_account(move=mvbox_move, mvbox=mvbox_move) + acfactory.wait_configure_and_start_io() + + acfactory.get_accepted_chat(ac1, ac2).send_text("hi") + msg = ac2._evtracker.wait_next_incoming_message() + + folder = "mvbox" if mvbox_move else "inbox" + ac1.direct_imap.select_config_folder(folder) + ac2.direct_imap.select_config_folder(folder) + ac1.direct_imap.idle_start() + ac2.direct_imap.idle_start() + + ac2.mark_seen_messages([msg]) + + ac1.direct_imap.idle_wait_for_seen() # Check that the mdn is marked as seen + ac2.direct_imap.idle_wait_for_seen() # Check that the original message is marked as seen + ac1.direct_imap.idle_done() + ac2.direct_imap.idle_done() + def test_reply_privately(self, acfactory): ac1, ac2 = acfactory.get_two_online_accounts() diff --git a/src/dc_receive_imf.rs b/src/dc_receive_imf.rs index 5b2c3bb8c..c1039bd50 100644 --- a/src/dc_receive_imf.rs +++ b/src/dc_receive_imf.rs @@ -836,8 +836,8 @@ async fn add_parts( if is_mdn || is_location_kml { is_hidden = true; - if state == MessageState::InFresh { - state = MessageState::InNoticed; + if state == MessageState::InFresh || state == MessageState::InNoticed { + state = MessageState::InSeen; // Set the state to InSeen so that precheck_imf() adds a markseen job after we moved the message } } diff --git a/src/imap/mod.rs b/src/imap/mod.rs index a8d55e59a..a0ab1f9e0 100644 --- a/src/imap/mod.rs +++ b/src/imap/mod.rs @@ -1521,6 +1521,7 @@ async fn precheck_imf( } if old_server_folder != server_folder || old_server_uid != server_uid { + info!(context, "Updating server uid"); update_server_uid(context, rfc724_mid, server_folder, server_uid).await; if let Ok(message_state) = msg_id.get_state(context).await { if message_state == MessageState::InSeen || message_state.is_outgoing() { @@ -1531,7 +1532,6 @@ async fn precheck_imf( .await; } } - info!(context, "Updating server_uid and adding markseen job"); } Ok(true) } else {