mirror of
https://github.com/chatmail/core.git
synced 2026-05-23 00:36:32 +03:00
fix: Fail receive_imf to not tombstone reaction if the referenced message isn't found
A reaction may arrive earler than the referenced message in case of multi-transport. By not creating a tombstone we still can receive it later on another transport.
This commit is contained in:
@@ -348,7 +348,7 @@ def test_receive_imf_failure(acfactory) -> None:
|
|||||||
snapshot.text == "❌ Failed to receive a message:"
|
snapshot.text == "❌ Failed to receive a message:"
|
||||||
" Condition failed: `!context.get_config_bool(Config::SimulateReceiveImfError).await?`."
|
" Condition failed: `!context.get_config_bool(Config::SimulateReceiveImfError).await?`."
|
||||||
f" Core version {version}."
|
f" Core version {version}."
|
||||||
" Please report this bug to delta@merlinux.eu or https://support.delta.chat/."
|
" Please report this bug to delta@merlinux.eu or https://support.delta.chat/"
|
||||||
)
|
)
|
||||||
|
|
||||||
# The failed message doesn't break the IMAP loop.
|
# The failed message doesn't break the IMAP loop.
|
||||||
|
|||||||
16
src/imap.rs
16
src/imap.rs
@@ -1383,13 +1383,15 @@ impl Session {
|
|||||||
let res = receive_imf_inner(context, rfc724_mid, body, is_seen).await;
|
let res = receive_imf_inner(context, rfc724_mid, body, is_seen).await;
|
||||||
let received_msg = match res {
|
let received_msg = match res {
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
warn!(context, "receive_imf error: {err:#}.");
|
let err = format!("{err:#}");
|
||||||
|
warn!(context, "receive_imf error: {err}.");
|
||||||
let text = format!(
|
if !err.contains("(SKIP_DEVICE_MSG)") {
|
||||||
"❌ Failed to receive a message: {err:#}. Core version v{DC_VERSION_STR}. Please report this bug to delta@merlinux.eu or https://support.delta.chat/.",
|
let text = format!(
|
||||||
);
|
"❌ Failed to receive a message: {err}. Core version v{DC_VERSION_STR}. Please report this bug to delta@merlinux.eu or https://support.delta.chat/",
|
||||||
let mut msg = Message::new_text(text);
|
);
|
||||||
add_device_msg(context, None, Some(&mut msg)).await?;
|
let mut msg = Message::new_text(text);
|
||||||
|
add_device_msg(context, None, Some(&mut msg)).await?;
|
||||||
|
}
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
Ok(msg) => msg,
|
Ok(msg) => msg,
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ use std::cmp::Ordering;
|
|||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::{Result, bail};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::chat::{Chat, ChatId, send_msg};
|
use crate::chat::{Chat, ChatId, send_msg};
|
||||||
@@ -259,9 +259,8 @@ pub(crate) async fn set_msg_reaction(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
info!(
|
bail!(
|
||||||
context,
|
"Can't assign reaction to unknown message with Message-ID {in_reply_to} (SKIP_DEVICE_MSG)"
|
||||||
"Can't assign reaction to unknown message with Message-ID {}", in_reply_to
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -519,6 +518,54 @@ Content-Disposition: reaction\n\
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
|
async fn test_reaction_and_multitransport() -> Result<()> {
|
||||||
|
let mut tcm = TestContextManager::new();
|
||||||
|
let alice = &tcm.alice().await;
|
||||||
|
let device_chat_id = ChatId::get_for_contact(alice, ContactId::DEVICE).await?;
|
||||||
|
let n_device_msgs = get_chat_msgs(alice, device_chat_id).await?.len();
|
||||||
|
|
||||||
|
let reaction_bytes = "To: alice@example.org, claire@example.org\n\
|
||||||
|
From: bob@example.net\n\
|
||||||
|
Date: Today, 29 February 2021 00:00:10 -800\n\
|
||||||
|
Message-ID: 56789@example.net\n\
|
||||||
|
In-Reply-To: 12345@example.org\n\
|
||||||
|
Content-Type: text/plain; charset=utf-8\n\
|
||||||
|
Content-Disposition: reaction\n\
|
||||||
|
\n\
|
||||||
|
\u{1F44D}"
|
||||||
|
.as_bytes();
|
||||||
|
// Alice receives a reaction to Claire's message from Bob earler than the message itself
|
||||||
|
// because Bob knows about Alice's new transport.
|
||||||
|
assert!(receive_imf(alice, reaction_bytes, false).await.is_err());
|
||||||
|
|
||||||
|
let msg_id = receive_imf(
|
||||||
|
alice,
|
||||||
|
"To: alice@example.org, bob@example.net\n\
|
||||||
|
From: claire@example.org\n\
|
||||||
|
Date: Today, 29 February 2021 00:00:00 -800\n\
|
||||||
|
Message-ID: 12345@example.org\n\
|
||||||
|
\n\
|
||||||
|
Can we chat at 1pm pacific, today?"
|
||||||
|
.as_bytes(),
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
.await?
|
||||||
|
.unwrap()
|
||||||
|
.msg_ids[0];
|
||||||
|
|
||||||
|
// Finally the reaction arrives on Alice's older transport.
|
||||||
|
receive_imf(alice, reaction_bytes, false).await?;
|
||||||
|
let reactions = get_msg_reactions(alice, msg_id).await?;
|
||||||
|
assert_eq!(reactions.to_string(), "👍1");
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
get_chat_msgs(alice, device_chat_id).await?.len(),
|
||||||
|
n_device_msgs
|
||||||
|
);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
async fn expect_reactions_changed_event(
|
async fn expect_reactions_changed_event(
|
||||||
t: &TestContext,
|
t: &TestContext,
|
||||||
expected_chat_id: ChatId,
|
expected_chat_id: ChatId,
|
||||||
|
|||||||
Reference in New Issue
Block a user