diff --git a/src/receive_imf.rs b/src/receive_imf.rs index 9858a56e3a..7cc4f05db1 100644 --- a/src/receive_imf.rs +++ b/src/receive_imf.rs @@ -54,6 +54,9 @@ pub struct ReceivedMsg { /// Received message state. pub state: MessageState, + /// Whether the message is hidden. + pub hidden: bool, + /// Message timestamp for sorting. pub sort_timestamp: i64, @@ -192,6 +195,7 @@ pub(crate) async fn receive_imf_inner( return Ok(Some(ReceivedMsg { chat_id: DC_CHAT_ID_TRASH, state: MessageState::Undefined, + hidden: false, sort_timestamp: 0, msg_ids, needs_delete_job: false, @@ -373,6 +377,7 @@ pub(crate) async fn receive_imf_inner( received_msg = Some(ReceivedMsg { chat_id: DC_CHAT_ID_TRASH, state: MessageState::InSeen, + hidden: false, sort_timestamp: mime_parser.timestamp_sent, msg_ids: vec![msg_id], needs_delete_job: res == securejoin::HandshakeMessage::Done, @@ -611,7 +616,11 @@ pub(crate) async fn receive_imf_inner( } else if !chat_id.is_trash() { let fresh = received_msg.state == MessageState::InFresh; for msg_id in &received_msg.msg_ids { - chat_id.emit_msg_event(context, *msg_id, mime_parser.incoming && fresh); + chat_id.emit_msg_event( + context, + *msg_id, + mime_parser.incoming && fresh && !received_msg.hidden, + ); } } context.new_msgs_notify.notify_one(); @@ -1018,7 +1027,14 @@ async fn add_parts( } } - state = if seen || fetching_existing_messages || is_mdn || chat_id_blocked == Blocked::Yes { + state = if seen + || fetching_existing_messages + || is_mdn + // Currently only reactions are hidden, so this check is just in case we have other + // hidden messages in the future to make `chat::marknoticed_chat()` no-op for them. + || (hidden && !is_reaction) + || chat_id_blocked == Blocked::Yes + { MessageState::InSeen } else { MessageState::InFresh @@ -1730,6 +1746,7 @@ RETURNING id Ok(ReceivedMsg { chat_id, state, + hidden, sort_timestamp, msg_ids: created_db_entries, needs_delete_job,