mirror of
https://github.com/chatmail/core.git
synced 2026-10-02 11:10:25 +03:00
a single NDN shall not mark a group message as errorneous
This commit is contained in:
+11
-12
@@ -2540,19 +2540,18 @@ async fn handle_ndn(
|
|||||||
for msg_id in msg_ids {
|
for msg_id in msg_ids {
|
||||||
let mut message = Message::load_from_db(context, msg_id).await?;
|
let mut message = Message::load_from_db(context, msg_id).await?;
|
||||||
let chat = Chat::load_from_db(context, message.chat_id).await?;
|
let chat = Chat::load_from_db(context, message.chat_id).await?;
|
||||||
if chat.typ == constants::Chattype::OutBroadcast {
|
if chat.typ == constants::Chattype::Single {
|
||||||
continue;
|
let aggregated_error = message
|
||||||
|
.error
|
||||||
|
.as_ref()
|
||||||
|
.map(|err| format!("{err}\n\n{err_msg}"));
|
||||||
|
set_msg_failed(
|
||||||
|
context,
|
||||||
|
&mut message,
|
||||||
|
aggregated_error.as_ref().unwrap_or(err_msg),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
}
|
}
|
||||||
let aggregated_error = message
|
|
||||||
.error
|
|
||||||
.as_ref()
|
|
||||||
.map(|err| format!("{err}\n\n{err_msg}"));
|
|
||||||
set_msg_failed(
|
|
||||||
context,
|
|
||||||
&mut message,
|
|
||||||
aggregated_error.as_ref().unwrap_or(err_msg),
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -726,6 +726,7 @@ async fn test_resend_after_ndn() -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// an NDN in a group does not make the whole message as failed
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
async fn test_parse_ndn_group_msg() -> Result<()> {
|
async fn test_parse_ndn_group_msg() -> Result<()> {
|
||||||
let t = TestContext::new().await;
|
let t = TestContext::new().await;
|
||||||
@@ -758,7 +759,7 @@ async fn test_parse_ndn_group_msg() -> Result<()> {
|
|||||||
|
|
||||||
let msg = Message::load_from_db(&t, msg_id).await?;
|
let msg = Message::load_from_db(&t, msg_id).await?;
|
||||||
|
|
||||||
assert_eq!(msg.state, MessageState::OutFailed);
|
assert_eq!(msg.state, MessageState::OutDelivered);
|
||||||
|
|
||||||
let msgs = chat::get_chat_msgs(&t, msg.chat_id).await?;
|
let msgs = chat::get_chat_msgs(&t, msg.chat_id).await?;
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
@@ -766,9 +767,6 @@ async fn test_parse_ndn_group_msg() -> Result<()> {
|
|||||||
ChatItem::Message { msg_id } if msg_id == msg.id
|
ChatItem::Message { msg_id } if msg_id == msg.id
|
||||||
));
|
));
|
||||||
|
|
||||||
t.assert_warn("Delivery Status Notification (Failure)")
|
|
||||||
.await;
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user