Fix: Make add_parts() not early-exit (#2879)

Fix #2867
This commit is contained in:
Hocuri
2021-12-09 19:04:32 +01:00
committed by GitHub
parent b166cc5bf4
commit 46eb391a1b

View File

@@ -235,9 +235,7 @@ pub(crate) async fn dc_receive_imf_inner(
// Update gossiped timestamp for the chat if someone else or our other device sent // Update gossiped timestamp for the chat if someone else or our other device sent
// Autocrypt-Gossip for all recipients in the chat to avoid sending Autocrypt-Gossip ourselves // Autocrypt-Gossip for all recipients in the chat to avoid sending Autocrypt-Gossip ourselves
// and waste traffic. // and waste traffic.
let chat_id = received_msg let chat_id = received_msg.chat_id;
.as_ref()
.map_or(DC_CHAT_ID_TRASH, |received_msg| received_msg.chat_id);
if !chat_id.is_special() if !chat_id.is_special()
&& mime_parser && mime_parser
.recipients .recipients
@@ -387,7 +385,7 @@ pub(crate) async fn dc_receive_imf_inner(
.handle_reports(context, from_id, sent_timestamp, &mime_parser.parts) .handle_reports(context, from_id, sent_timestamp, &mime_parser.parts)
.await; .await;
Ok(received_msg) Ok(Some(received_msg))
} }
/// Converts "From" field to contact id. /// Converts "From" field to contact id.
@@ -457,7 +455,7 @@ async fn add_parts(
create_event_to_send: &mut Option<CreateEvent>, create_event_to_send: &mut Option<CreateEvent>,
fetching_existing_messages: bool, fetching_existing_messages: bool,
prevent_rename: bool, prevent_rename: bool,
) -> Result<Option<ReceivedMsg>> { ) -> Result<ReceivedMsg> {
let mut chat_id = None; let mut chat_id = None;
let mut chat_id_blocked = Blocked::Not; let mut chat_id_blocked = Blocked::Not;
let mut incoming_origin = incoming_origin; let mut incoming_origin = incoming_origin;
@@ -531,7 +529,8 @@ async fn add_parts(
} }
Err(err) => { Err(err) => {
warn!(context, "Error in Secure-Join message handling: {}", err); warn!(context, "Error in Secure-Join message handling: {}", err);
return Ok(None); chat_id = Some(DC_CHAT_ID_TRASH);
securejoin_seen = true;
} }
} }
} else { } else {
@@ -758,7 +757,7 @@ async fn add_parts(
} }
Err(err) => { Err(err) => {
warn!(context, "Error in Secure-Join watching: {}", err); warn!(context, "Error in Secure-Join watching: {}", err);
return Ok(None); chat_id = Some(DC_CHAT_ID_TRASH);
} }
} }
} else if mime_parser.sync_items.is_some() && self_sent { } else if mime_parser.sync_items.is_some() && self_sent {
@@ -1033,7 +1032,7 @@ async fn add_parts(
sort_timestamp, sort_timestamp,
) )
.await?; .await?;
return Ok(None); // do not return an error as this would result in retrying the message // do not return an error as this would result in retrying the message
} }
} }
set_better_msg( set_better_msg(
@@ -1251,11 +1250,11 @@ INSERT INTO msgs
} }
} }
Ok(Some(ReceivedMsg { Ok(ReceivedMsg {
chat_id, chat_id,
state, state,
sort_timestamp, sort_timestamp,
})) })
} }
/// Saves attached locations to the database. /// Saves attached locations to the database.