-
-
Notifications
You must be signed in to change notification settings - Fork 107
feat: Don't ignore receive_imf_inner() errors, try adding partially downloaded message instead (#7196) #7222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -196,7 +196,7 @@ pub(crate) async fn receive_imf_from_inbox( | |
rfc724_mid, | ||
imf_raw, | ||
seen, | ||
is_partial_download, | ||
is_partial_download.map(|msg_size| (msg_size, None)), | ||
) | ||
.await | ||
} | ||
|
@@ -494,9 +494,8 @@ async fn get_to_and_past_contact_ids( | |
/// If the message is so wrong that we didn't even create a database entry, | ||
/// returns `Ok(None)`. | ||
/// | ||
/// If `is_partial_download` is set, it contains the full message size in bytes. | ||
/// Do not confuse that with `replace_msg_id` that will be set when the full message is loaded | ||
/// later. | ||
/// If `partial` is set, it contains the full message size in bytes and an optional error text for | ||
/// the partially downloaded message. | ||
#[expect(clippy::too_many_arguments)] | ||
pub(crate) async fn receive_imf_inner( | ||
context: &Context, | ||
|
@@ -506,7 +505,7 @@ pub(crate) async fn receive_imf_inner( | |
rfc724_mid: &str, | ||
imf_raw: &[u8], | ||
seen: bool, | ||
is_partial_download: Option<u32>, | ||
partial: Option<(u32, Option<String>)>, | ||
) -> Result<Option<ReceivedMsg>> { | ||
if std::env::var(crate::DCC_MIME_DEBUG).is_ok() { | ||
info!( | ||
|
@@ -515,9 +514,16 @@ pub(crate) async fn receive_imf_inner( | |
String::from_utf8_lossy(imf_raw), | ||
); | ||
} | ||
if partial.is_none() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why restrict this to non-partial downloads? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is necessary to test the new logic in |
||
ensure!( | ||
!context | ||
.get_config_bool(Config::FailOnReceivingFullMsg) | ||
.await? | ||
); | ||
} | ||
|
||
let mut mime_parser = match MimeMessage::from_bytes(context, imf_raw, is_partial_download).await | ||
{ | ||
let is_partial_download = partial.as_ref().map(|(msg_size, _err)| *msg_size); | ||
let mut mime_parser = match MimeMessage::from_bytes(context, imf_raw, partial).await { | ||
Err(err) => { | ||
warn!(context, "receive_imf: can't parse MIME: {err:#}."); | ||
if rfc724_mid.starts_with(GENERATED_PREFIX) { | ||
|
@@ -551,22 +557,11 @@ pub(crate) async fn receive_imf_inner( | |
// make sure, this check is done eg. before securejoin-processing. | ||
let (replace_msg_id, replace_chat_id); | ||
if let Some((old_msg_id, _)) = message::rfc724_mid_exists(context, rfc724_mid).await? { | ||
if is_partial_download.is_some() { | ||
// Should never happen, see imap::prefetch_should_download(), but still. | ||
info!( | ||
context, | ||
"Got a partial download and message is already in DB." | ||
); | ||
return Ok(None); | ||
} | ||
let msg = Message::load_from_db(context, old_msg_id).await?; | ||
replace_msg_id = Some(old_msg_id); | ||
replace_chat_id = if msg.download_state() != DownloadState::Done { | ||
// the message was partially downloaded before and is fully downloaded now. | ||
info!( | ||
context, | ||
"Message already partly in DB, replacing by full message." | ||
); | ||
info!(context, "Message already partly in DB, replacing."); | ||
Some(msg.chat_id) | ||
} else { | ||
None | ||
|
@@ -1007,7 +1002,10 @@ pub(crate) async fn receive_imf_inner( | |
} else if received_msg.hidden { | ||
// No need to emit an event about the changed message | ||
} else if let Some(replace_chat_id) = replace_chat_id { | ||
context.emit_msgs_changed_without_msg_id(replace_chat_id); | ||
match replace_chat_id == chat_id { | ||
false => context.emit_msgs_changed_without_msg_id(replace_chat_id), | ||
true => context.emit_msgs_changed(chat_id, replace_msg_id.unwrap_or_default()), | ||
iequidoo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} else if !chat_id.is_trash() { | ||
let fresh = received_msg.state == MessageState::InFresh | ||
&& mime_parser.is_system_message != SystemMessage::CallAccepted | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UIs already display a red exclamation mark on the message bubble, no need to add it inside the message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They display it for
OutFailed
messages. If justerror
is set, they don't display anything. At least Desktop doesn't