mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 17:36:29 +03:00
fix: Fail receive_imf to not tombstone self-MDN if original message isn't found
This commit is contained in:
@@ -2031,6 +2031,7 @@ async fn add_parts(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !mime_parser.incoming && !context.get_config_bool(Config::TeamProfile).await? {
|
if !mime_parser.incoming && !context.get_config_bool(Config::TeamProfile).await? {
|
||||||
|
let mut missing_rfc724_mid = None;
|
||||||
let mut updated_chats = BTreeMap::new();
|
let mut updated_chats = BTreeMap::new();
|
||||||
let mut archived_chats_maybe_noticed = false;
|
let mut archived_chats_maybe_noticed = false;
|
||||||
for report in &mime_parser.mdn_reports {
|
for report in &mime_parser.mdn_reports {
|
||||||
@@ -2040,6 +2041,7 @@ async fn add_parts(
|
|||||||
.chain(&report.additional_message_ids)
|
.chain(&report.additional_message_ids)
|
||||||
{
|
{
|
||||||
let Some(msg_id) = rfc724_mid_exists(context, msg_rfc724_mid).await? else {
|
let Some(msg_id) = rfc724_mid_exists(context, msg_rfc724_mid).await? else {
|
||||||
|
missing_rfc724_mid.get_or_insert(msg_rfc724_mid.as_str());
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
let Some(msg) = Message::load_from_db_optional(context, msg_id).await? else {
|
let Some(msg) = Message::load_from_db_optional(context, msg_id).await? else {
|
||||||
@@ -2098,6 +2100,11 @@ chat_id=? AND
|
|||||||
if archived_chats_maybe_noticed {
|
if archived_chats_maybe_noticed {
|
||||||
context.on_archived_chats_maybe_noticed();
|
context.on_archived_chats_maybe_noticed();
|
||||||
}
|
}
|
||||||
|
ensure!(
|
||||||
|
missing_rfc724_mid.is_none(),
|
||||||
|
"Self-MDN: {} not found (SKIP_DEVICE_MSG)",
|
||||||
|
missing_rfc724_mid.unwrap_or(""),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let hidden = mime_parser.parts.iter().all(|part| part.is_reaction);
|
let hidden = mime_parser.parts.iter().all(|part| part.is_reaction);
|
||||||
|
|||||||
@@ -14,7 +14,9 @@ use crate::contact;
|
|||||||
use crate::imap::prefetch_should_download;
|
use crate::imap::prefetch_should_download;
|
||||||
use crate::imex::{ImexMode, imex};
|
use crate::imex::{ImexMode, imex};
|
||||||
use crate::key;
|
use crate::key;
|
||||||
|
use crate::message::markseen_msgs;
|
||||||
use crate::securejoin::get_securejoin_qr;
|
use crate::securejoin::get_securejoin_qr;
|
||||||
|
use crate::smtp;
|
||||||
use crate::test_utils::{
|
use crate::test_utils::{
|
||||||
TestContext, TestContextManager, alice_keypair, get_chat_msg, mark_as_verified,
|
TestContext, TestContextManager, alice_keypair, get_chat_msg, mark_as_verified,
|
||||||
};
|
};
|
||||||
@@ -2655,6 +2657,32 @@ async fn test_read_receipts_dont_unmark_bots() -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
|
async fn test_self_mdn_before_msg() -> Result<()> {
|
||||||
|
let mut tcm = TestContextManager::new();
|
||||||
|
let alice = &tcm.alice().await;
|
||||||
|
let bob = &tcm.bob().await;
|
||||||
|
let bob2 = &tcm.bob().await;
|
||||||
|
let alice_chat = alice.create_chat(bob).await;
|
||||||
|
|
||||||
|
let sent = alice.send_text(alice_chat.id, "hi").await;
|
||||||
|
let msg = bob.recv_msg(&sent).await;
|
||||||
|
msg.chat_id.accept(bob).await?;
|
||||||
|
markseen_msgs(bob, vec![msg.id]).await?;
|
||||||
|
smtp::queue_mdn(bob).await?;
|
||||||
|
let sent_mdn = bob.pop_sent_msg().await;
|
||||||
|
|
||||||
|
let Err(err) = receive_imf(bob2, sent_mdn.payload().as_bytes(), false).await else {
|
||||||
|
unreachable!();
|
||||||
|
};
|
||||||
|
assert!(format!("{err:#}").contains("(SKIP_DEVICE_MSG)"));
|
||||||
|
let msg = bob2.recv_msg(&sent).await;
|
||||||
|
assert_eq!(msg.get_state(), MessageState::InFresh);
|
||||||
|
bob2.recv_msg_trash(&sent_mdn).await;
|
||||||
|
assert_eq!(msg.id.get_state(bob2).await?, MessageState::InSeen);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
async fn test_gmx_forwarded_msg() -> Result<()> {
|
async fn test_gmx_forwarded_msg() -> Result<()> {
|
||||||
let t = TestContext::new_alice().await;
|
let t = TestContext::new_alice().await;
|
||||||
|
|||||||
Reference in New Issue
Block a user