From 2f94731475537565c92d2c705d06a08e2a67ffe2 Mon Sep 17 00:00:00 2001 From: Hocuri Date: Fri, 8 May 2026 16:41:16 +0200 Subject: [PATCH] refactor: No need to fail receive_imf, we can just exit normally --- src/reaction.rs | 12 +++++++----- src/receive_imf.rs | 14 ++++++++++++-- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/reaction.rs b/src/reaction.rs index 3d2f3d2c1..99a39f44e 100644 --- a/src/reaction.rs +++ b/src/reaction.rs @@ -243,7 +243,7 @@ pub(crate) async fn set_msg_reaction( timestamp: i64, reaction: Reaction, is_incoming_fresh: bool, -) -> Result<()> { +) -> Result { 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?; @@ -258,12 +258,14 @@ pub(crate) async fn set_msg_reaction( reaction, }); } + Ok(true) } else { - bail!( - "Can't assign reaction to unknown message with Message-ID {in_reply_to} (SKIP_DEVICE_MSG)" + info!( + 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. @@ -537,7 +539,7 @@ Content-Disposition: reaction\n\ .as_bytes(); // Alice receives a reaction to Claire's message from Bob earler than the message itself // 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( alice, diff --git a/src/receive_imf.rs b/src/receive_imf.rs index 87773ddf7..04eab4ded 100644 --- a/src/receive_imf.rs +++ b/src/receive_imf.rs @@ -2114,7 +2114,7 @@ chat_id=? AND if part.is_reaction { let reaction_str = simplify::remove_footers(part.msg.as_str()); let is_incoming_fresh = mime_parser.incoming && !seen; - set_msg_reaction( + if !set_msg_reaction( context, mime_in_reply_to, chat_id, @@ -2123,7 +2123,17 @@ chat_id=? AND Reaction::new(reaction_str.as_str()), 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();