refactor: No need to fail receive_imf, we can just exit normally

This commit is contained in:
Hocuri
2026-05-08 16:41:16 +02:00
parent 67a75a432c
commit 2f94731475
2 changed files with 19 additions and 7 deletions

View File

@@ -243,7 +243,7 @@ pub(crate) async fn set_msg_reaction(
timestamp: i64, timestamp: i64,
reaction: Reaction, reaction: Reaction,
is_incoming_fresh: bool, is_incoming_fresh: bool,
) -> Result<()> { ) -> Result<bool> {
if let Some(msg_id) = rfc724_mid_exists(context, in_reply_to).await? { if let Some(msg_id) = rfc724_mid_exists(context, in_reply_to).await? {
set_msg_id_reaction(context, msg_id, chat_id, contact_id, timestamp, &reaction).await?; set_msg_id_reaction(context, msg_id, chat_id, contact_id, timestamp, &reaction).await?;
@@ -258,12 +258,14 @@ pub(crate) async fn set_msg_reaction(
reaction, reaction,
}); });
} }
Ok(true)
} else { } else {
bail!( info!(
"Can't assign reaction to unknown message with Message-ID {in_reply_to} (SKIP_DEVICE_MSG)" context,
"Can't assign reaction to unknown message with Message-ID {}", in_reply_to
); );
Ok(false)
} }
Ok(())
} }
/// Returns a structure containing all reactions to the message. /// Returns a structure containing all reactions to the message.
@@ -537,7 +539,7 @@ Content-Disposition: reaction\n\
.as_bytes(); .as_bytes();
// Alice receives a reaction to Claire's message from Bob earler than the message itself // Alice receives a reaction to Claire's message from Bob earler than the message itself
// because Bob knows about Alice's new transport. // because Bob knows about Alice's new transport.
assert!(receive_imf(alice, reaction_bytes, false).await.is_err()); receive_imf(alice, reaction_bytes, false).await?;
let msg_id = receive_imf( let msg_id = receive_imf(
alice, alice,

View File

@@ -2114,7 +2114,7 @@ chat_id=? AND
if part.is_reaction { if part.is_reaction {
let reaction_str = simplify::remove_footers(part.msg.as_str()); let reaction_str = simplify::remove_footers(part.msg.as_str());
let is_incoming_fresh = mime_parser.incoming && !seen; let is_incoming_fresh = mime_parser.incoming && !seen;
set_msg_reaction( if !set_msg_reaction(
context, context,
mime_in_reply_to, mime_in_reply_to,
chat_id, chat_id,
@@ -2123,7 +2123,17 @@ chat_id=? AND
Reaction::new(reaction_str.as_str()), Reaction::new(reaction_str.as_str()),
is_incoming_fresh, is_incoming_fresh,
) )
.await?; .await?
{
return Ok(ReceivedMsg {
chat_id,
state,
hidden,
sort_timestamp,
msg_ids: vec![],
needs_delete_job: false,
});
}
} }
let mut param = part.param.clone(); let mut param = part.param.clone();