Skip to content

Commit

Permalink
2squash: make reactions tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
iequidoo committed Nov 26, 2024
1 parent cdc0326 commit 110f0d3
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/receive_imf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1730,6 +1746,7 @@ RETURNING id
Ok(ReceivedMsg {
chat_id,
state,
hidden,
sort_timestamp,
msg_ids: created_db_entries,
needs_delete_job,
Expand Down

0 comments on commit 110f0d3

Please sign in to comment.