Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion src/reaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -550,6 +550,46 @@ Here's my footer -- [email protected]"
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: [email protected]\n\
From: [email protected]\n\
Date: Today, 29 February 2021 00:00:10 -800\n\
Message-ID: [email protected]\n\
In-Reply-To: [email protected]\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(())
}

Expand Down
7 changes: 3 additions & 4 deletions src/receive_imf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down
Loading