diff --git a/src/reaction.rs b/src/reaction.rs index 685f811c95..6b90e0947f 100644 --- a/src/reaction.rs +++ b/src/reaction.rs @@ -404,7 +404,7 @@ mod tests { use crate::config::Config; use crate::contact::{Contact, Origin}; use crate::download::DownloadState; - use crate::message::{MessageState, delete_msgs}; + use crate::message::{MessageState, Viewtype, delete_msgs}; use crate::receive_imf::{receive_imf, receive_imf_from_inbox}; use crate::sql::housekeeping; use crate::test_utils::E2EE_INFO_MSGS; @@ -550,6 +550,46 @@ Here's my footer -- bob@example.net" let reactions = get_msg_reactions(&alice, msg.id).await?; assert_eq!(reactions.to_string(), "😀1"); + // Alice receives a message with reaction to her message from Bob. + let msg_bob = receive_imf( + &alice, + "To: alice@example.org\n\ +From: bob@example.net\n\ +Date: Today, 29 February 2021 00:00:10 -800\n\ +Message-ID: 56791@example.net\n\ +In-Reply-To: 12345@example.org\n\ +Mime-Version: 1.0\n\ +Content-Type: multipart/mixed; boundary=\"YiEDa0DAkWCtVeE4\"\n\ +Content-Disposition: inline\n\ +\n\ +--YiEDa0DAkWCtVeE4\n\ +Content-Type: text/plain; charset=utf-8\n\ +Content-Disposition: inline\n\ +\n\ +Reply + reaction\n\ +\n\ +--YiEDa0DAkWCtVeE4\n\ +Content-Type: text/plain; charset=utf-8\n\ +Content-Disposition: reaction\n\ +\n\ +\u{1F44D}\n\ +\n\ +--YiEDa0DAkWCtVeE4--" + .as_bytes(), + false, + ) + .await? + .unwrap(); + let msg_bob = Message::load_from_db(&alice, msg_bob.msg_ids[0]).await?; + assert_eq!(msg_bob.from_id, bob_id); + assert_eq!(msg_bob.chat_id, msg.chat_id); + assert_eq!(msg_bob.viewtype, Viewtype::Text); + assert_eq!(msg_bob.state, MessageState::InFresh); + assert_eq!(msg_bob.hidden, false); + assert_eq!(msg_bob.text, "Reply + reaction"); + let reactions = get_msg_reactions(&alice, msg.id).await?; + assert_eq!(reactions.to_string(), "👍1"); + Ok(()) } diff --git a/src/receive_imf.rs b/src/receive_imf.rs index 185a2626d0..03375862f4 100644 --- a/src/receive_imf.rs +++ b/src/receive_imf.rs @@ -763,7 +763,6 @@ pub(crate) async fn receive_imf_inner( let show_emails = ShowEmails::from_i32(context.get_config_int(Config::ShowEmails).await?) .unwrap_or_default(); - let is_reaction = mime_parser.parts.iter().any(|part| part.is_reaction); let allow_creation = if mime_parser.decrypting_failed { false } else if mime_parser.is_system_message != SystemMessage::AutocryptSetupMessage @@ -777,7 +776,7 @@ pub(crate) async fn receive_imf_inner( ShowEmails::All => true, } } else { - !is_reaction + !mime_parser.parts.iter().all(|part| part.is_reaction) }; let to_id = if mime_parser.incoming { @@ -1995,10 +1994,10 @@ async fn add_parts( handle_edit_delete(context, mime_parser, from_id).await?; - let is_reaction = mime_parser.parts.iter().any(|part| part.is_reaction); - let hidden = is_reaction; + let hidden = mime_parser.parts.iter().all(|part| part.is_reaction); let mut parts = mime_parser.parts.iter().peekable(); while let Some(part) = parts.next() { + let hidden = part.is_reaction; if part.is_reaction { let reaction_str = simplify::remove_footers(part.msg.as_str()); let is_incoming_fresh = mime_parser.incoming && !seen;