mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
fix: Make reaction message hidden only if there are no other parts
RFC 9078 "Reaction: ..." doesn't forbid messages with reactions to have other parts, so be prepared for this.
This commit is contained in:
@@ -404,7 +404,7 @@ mod tests {
|
|||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::contact::{Contact, Origin};
|
use crate::contact::{Contact, Origin};
|
||||||
use crate::download::DownloadState;
|
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::receive_imf::{receive_imf, receive_imf_from_inbox};
|
||||||
use crate::sql::housekeeping;
|
use crate::sql::housekeeping;
|
||||||
use crate::test_utils::E2EE_INFO_MSGS;
|
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?;
|
let reactions = get_msg_reactions(&alice, msg.id).await?;
|
||||||
assert_eq!(reactions.to_string(), "😀1");
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -763,7 +763,6 @@ pub(crate) async fn receive_imf_inner(
|
|||||||
let show_emails = ShowEmails::from_i32(context.get_config_int(Config::ShowEmails).await?)
|
let show_emails = ShowEmails::from_i32(context.get_config_int(Config::ShowEmails).await?)
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
||||||
let is_reaction = mime_parser.parts.iter().any(|part| part.is_reaction);
|
|
||||||
let allow_creation = if mime_parser.decrypting_failed {
|
let allow_creation = if mime_parser.decrypting_failed {
|
||||||
false
|
false
|
||||||
} else if mime_parser.is_system_message != SystemMessage::AutocryptSetupMessage
|
} else if mime_parser.is_system_message != SystemMessage::AutocryptSetupMessage
|
||||||
@@ -777,7 +776,7 @@ pub(crate) async fn receive_imf_inner(
|
|||||||
ShowEmails::All => true,
|
ShowEmails::All => true,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
!is_reaction
|
!mime_parser.parts.iter().all(|part| part.is_reaction)
|
||||||
};
|
};
|
||||||
|
|
||||||
let to_id = if mime_parser.incoming {
|
let to_id = if mime_parser.incoming {
|
||||||
@@ -1995,10 +1994,10 @@ async fn add_parts(
|
|||||||
|
|
||||||
handle_edit_delete(context, mime_parser, from_id).await?;
|
handle_edit_delete(context, mime_parser, from_id).await?;
|
||||||
|
|
||||||
let is_reaction = mime_parser.parts.iter().any(|part| part.is_reaction);
|
let hidden = mime_parser.parts.iter().all(|part| part.is_reaction);
|
||||||
let hidden = is_reaction;
|
|
||||||
let mut parts = mime_parser.parts.iter().peekable();
|
let mut parts = mime_parser.parts.iter().peekable();
|
||||||
while let Some(part) = parts.next() {
|
while let Some(part) = parts.next() {
|
||||||
|
let hidden = part.is_reaction;
|
||||||
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;
|
||||||
|
|||||||
Reference in New Issue
Block a user