fix: Mark older messages as noticed on receipt of large outgoing message w/o pre-message

If a pre-message is lost or delayed, or doesn't exist at all, download_msg() adds a new message
instead of replacing an existing one. chat::mark_old_messages_as_noticed() must be called in this
case.
This commit is contained in:
iequidoo
2026-05-25 01:29:31 -03:00
parent 50e83f2072
commit bfc7e121b7

View File

@@ -2,10 +2,11 @@
use std::collections::BTreeMap;
use anyhow::{Result, anyhow, bail, ensure};
use anyhow::{Context as _, Result, anyhow, bail, ensure};
use deltachat_derive::{FromSql, ToSql};
use serde::{Deserialize, Serialize};
use crate::chat;
use crate::config::Config;
use crate::context::Context;
use crate::imap::session::Session;
@@ -131,9 +132,9 @@ impl Message {
}
}
/// Actually downloads a message partially downloaded before if the message is available on the
/// session transport, in which case returns `Some`. If the message is available on another
/// transport, returns `None`.
/// Actually downloads a message, normally partially downloaded before (if it's an encrypted chat
/// message and the pre-message isn't lost), if the message is available on the session transport,
/// in which case returns `Some`. If the message is available on another transport, returns `None`.
///
/// Most messages are downloaded automatically on fetch instead.
pub(crate) async fn download_msg(
@@ -212,9 +213,15 @@ impl Session {
self.fetch_many_msgs(context, folder, vec![uid], &uid_message_ids, sender)
.await?;
}
if receiver.recv().await.is_err() {
bail!("Failed to fetch UID {uid}");
let mut received_msgs = Vec::with_capacity(1);
if let (_, Some(msg)) = receiver
.recv()
.await
.with_context(|| format!("Failed to fetch UID {uid}"))?
{
received_msgs.push(msg);
}
chat::mark_old_messages_as_noticed(context, received_msgs).await?;
Ok(())
}
}