Compare commits

..

2 Commits

Author SHA1 Message Date
iequidoo
db56e69d4b feat: Don't mark MDNs as IMAP-seen
Marking MDNs as seen is useless, they shouldn't be displayed by any MUA.
2026-05-05 13:50:14 -03:00
iequidoo
65d07d18a5 fix: Avoid auto-marking DSNs as seen; the user may want to see them in another MUA 2026-05-05 12:02:52 -03:00
8 changed files with 19 additions and 50 deletions

View File

@@ -68,12 +68,11 @@ def test_markseen_message_and_mdn(acfactory, direct_imap):
msg.mark_seen()
rex = re.compile("Marked messages [0-9]+ in folder INBOX as seen.")
for ac in ac1, ac2:
while True:
event = ac.wait_for_event()
if event.kind == EventType.INFO and rex.search(event.msg):
break
while True:
event = ac2.wait_for_event()
if event.kind == EventType.INFO and rex.search(event.msg):
break
ac1.wait_for_msg(EventType.MSGS_CHANGED)
ac1_direct_imap = direct_imap(ac1)
ac2_direct_imap = direct_imap(ac2)
@@ -81,8 +80,8 @@ def test_markseen_message_and_mdn(acfactory, direct_imap):
ac1_direct_imap.select_folder("INBOX")
ac2_direct_imap.select_folder("INBOX")
# Check that the mdn is marked as seen
assert len(list(ac1_direct_imap.conn.fetch(AND(seen=True), mark_seen=False))) == 1
# Check that the MDN isn't marked as seen.
assert len(list(ac1_direct_imap.conn.fetch(AND(seen=True), mark_seen=False))) == 0
# Check original message is marked as seen
assert len(list(ac2_direct_imap.conn.fetch(AND(seen=True), mark_seen=False))) == 1

View File

@@ -419,9 +419,6 @@ def test_send_and_receive_message_markseen(acfactory, lp):
assert ev.data2 > dc.const.DC_MSG_ID_LAST_SPECIAL
lp.step("2")
# Check that ac1 marks the read receipt as read.
ac1._evtracker.get_info_contains("Marked messages .* in folder INBOX as seen.")
assert msg1.is_out_mdn_received()
assert msg3.is_out_mdn_received()
@@ -506,11 +503,16 @@ def test_mdn_asymmetric(acfactory, lp):
ac1.set_config("mdns_enabled", "1")
ac2.set_config("mdns_enabled", "1")
ac1.set_config("bcc_self", "1")
lp.sec("sending text message from ac1 to ac2")
msg_out = chat.send_text("message1")
assert len(chat.get_messages()) == 1 + E2EE_INFO_MSGS
# Wait for the message to be marked as seen on IMAP.
ac1._evtracker.get_info_contains("Marked messages [0-9]+ in folder INBOX as seen.")
lp.sec("disable ac1 MDNs")
ac1.set_config("mdns_enabled", "0")
@@ -522,13 +524,14 @@ def test_mdn_asymmetric(acfactory, lp):
lp.sec("ac2: mark incoming message as seen")
ac2.mark_seen_messages([msg])
# Wait for the message to be marked as seen on IMAP.
ac2._evtracker.get_info_contains("Marked messages [0-9]+ in folder INBOX as seen.")
lp.sec("ac1: waiting for incoming activity")
assert len(chat.get_messages()) == 1 + E2EE_INFO_MSGS
# Wait for the message to be marked as seen on IMAP.
ac1._evtracker.get_info_contains("Marked messages [0-9]+ in folder INBOX as seen.")
# MDN is received even though MDNs are already disabled
ac1._evtracker.get_matching("DC_EVENT_MSG_READ")
assert msg_out.is_out_mdn_received()

View File

@@ -473,7 +473,6 @@ mod tests {
add_contact_to_chat, create_broadcast, create_group, get_chat_contacts,
remove_contact_from_chat, send_text_msg, set_chat_name,
};
use crate::config::Config;
use crate::receive_imf::receive_imf;
use crate::securejoin::get_securejoin_qr;
use crate::stock_str::StockMessage;
@@ -666,7 +665,6 @@ mod tests {
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_search_single_chat() -> anyhow::Result<()> {
let t = TestContext::new_alice().await;
t.set_config(Config::ProcessUnencrypted, Some("1")).await?;
// receive a one-to-one-message
receive_imf(
@@ -727,7 +725,6 @@ mod tests {
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_search_single_chat_without_authname() -> anyhow::Result<()> {
let t = TestContext::new_alice().await;
t.set_config(Config::ProcessUnencrypted, Some("1")).await?;
// receive a one-to-one-message without authname set
receive_imf(

View File

@@ -486,11 +486,6 @@ pub enum Config {
/// Experimental option denoting that the current profile is shared between multiple team members.
/// For now, the only effect of this option is that seen flags are not synchronized.
TeamProfile,
/// Process unencrypted messages.
///
/// Unencrypted messages are fetched and processed only if this setting is explicitly enabled.
ProcessUnencrypted,
}
impl Config {

View File

@@ -1056,12 +1056,6 @@ impl Context {
"team_profile",
self.get_config_bool(Config::TeamProfile).await?.to_string(),
);
res.insert(
"process_unencrypted",
self.get_config_bool(Config::ProcessUnencrypted)
.await?
.to_string(),
);
let elapsed = time_elapsed(&self.creation_time);
res.insert("uptime", duration_to_str(elapsed));

View File

@@ -1996,21 +1996,12 @@ pub(crate) async fn prefetch_should_download(
// prevent_rename=true as this might be a mailing list message and in this case it would be bad if we rename the contact.
// (prevent_rename is the last argument of from_field_to_contact_id())
let is_encrypted = if let Some(content_type) = headers.get_header_value(HeaderDef::ContentType)
{
mailparse::parse_content_type(&content_type).mimetype == "multipart/encrypted"
} else {
false
};
if flags.any(|f| f == Flag::Draft) {
info!(context, "Ignoring draft message");
return Ok(false);
}
let should_download = maybe_ndn
|| (!blocked_contact
&& (is_encrypted || context.get_config_bool(Config::ProcessUnencrypted).await?));
let should_download = !blocked_contact || maybe_ndn;
Ok(should_download)
}

View File

@@ -21,7 +21,6 @@ const PREFETCH_FLAGS: &str = "(UID RFC822.SIZE BODY.PEEK[HEADER.FIELDS (\
DATE \
X-MICROSOFT-ORIGINAL-MESSAGE-ID \
FROM \
CONTENT-TYPE \
CHAT-VERSION \
CHAT-IS-POST-MESSAGE \
AUTOCRYPT-SETUP-MESSAGE\

View File

@@ -505,11 +505,6 @@ pub(crate) async fn receive_imf_inner(
Ok(mime_parser) => mime_parser,
};
if !mime_parser.was_encrypted() && !context.get_config_bool(Config::ProcessUnencrypted).await? {
warn!(context, "Fetched unencrypted message, ignoring");
return trash().await;
}
let rfc724_mid_orig = &mime_parser
.get_rfc724_mid()
.unwrap_or(rfc724_mid.to_string());
@@ -935,11 +930,6 @@ UPDATE config SET value=? WHERE keyname='configured_addr' AND value!=?1
.await?;
context.scheduler.interrupt_inbox().await;
}
if target.is_none() && !mime_parser.mdn_reports.is_empty() && mime_parser.has_chat_version()
{
// This is a Delta Chat MDN. Mark as read.
markseen_on_imap_table(context, rfc724_mid_orig).await?;
}
if !mime_parser.incoming && !context.get_config_bool(Config::TeamProfile).await? {
let mut updated_chats = BTreeMap::new();
let mut archived_chats_maybe_noticed = false;
@@ -1167,8 +1157,9 @@ async fn decide_chat_assignment(
info!(context, "Message is an MDN (TRASH).");
true
} else if mime_parser.delivery_report.is_some() {
// Auto-marking DSNs as IMAP-seen should be avoided because the user may want to see them in
// another MUA.
info!(context, "Message is a DSN (TRASH).");
markseen_on_imap_table(context, rfc724_mid).await.ok();
true
} else if mime_parser.get_header(HeaderDef::ChatEdit).is_some()
|| mime_parser.get_header(HeaderDef::ChatDelete).is_some()