From 1d4a1a684c1b893bcc9fdd32fe7a1f0e3da8faf9 Mon Sep 17 00:00:00 2001 From: mb Date: Mon, 4 Mar 2024 16:17:35 +0100 Subject: [PATCH] fix: Target messages for chat markers via StanzaId in MUC rooms (refs #60) --- .../src/domain/messaging/models/message.rs | 7 +++++-- .../src/domain/messaging/models/message_parser.rs | 10 ++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/crates/prose-core-client/src/domain/messaging/models/message.rs b/crates/prose-core-client/src/domain/messaging/models/message.rs index 8e55d217..e2474106 100644 --- a/crates/prose-core-client/src/domain/messaging/models/message.rs +++ b/crates/prose-core-client/src/domain/messaging/models/message.rs @@ -8,7 +8,7 @@ use std::collections::HashMap; use chrono::{DateTime, Utc}; use indexmap::IndexMap; use serde::{Deserialize, Serialize}; -use tracing::{error, warn}; +use tracing::{error, info, warn}; use prose_utils::id_string; @@ -117,7 +117,10 @@ impl Message { MessageTargetId::MessageId(ref id) => id, MessageTargetId::StanzaId(stanza_id) => { let Some(id) = stanza_to_id_map.get(&stanza_id) else { - error!("Could not resolve StanzaId '{stanza_id}' to a MessageId"); + info!( + "Could not resolve StanzaId '{stanza_id}' to a MessageId \n{:?}\n{:?}", + stanza_to_id_map, messages_map + ); continue; }; id diff --git a/crates/prose-core-client/src/domain/messaging/models/message_parser.rs b/crates/prose-core-client/src/domain/messaging/models/message_parser.rs index d74accd3..3a47bac8 100644 --- a/crates/prose-core-client/src/domain/messaging/models/message_parser.rs +++ b/crates/prose-core-client/src/domain/messaging/models/message_parser.rs @@ -144,14 +144,20 @@ impl TryFrom<&Message> for TargetedPayload { if let Some(marker) = message.received_marker() { return Ok(TargetedPayload { - target: Some(MessageTargetId::MessageId(marker.id.as_ref().into())), + target: Some(match message.type_ { + MessageType::Groupchat => MessageTargetId::StanzaId(marker.id.as_ref().into()), + _ => MessageTargetId::MessageId(marker.id.as_ref().into()), + }), payload: Payload::DeliveryReceipt, }); } if let Some(marker) = message.displayed_marker() { return Ok(TargetedPayload { - target: Some(MessageTargetId::MessageId(marker.id.as_ref().into())), + target: Some(match message.type_ { + MessageType::Groupchat => MessageTargetId::StanzaId(marker.id.as_ref().into()), + _ => MessageTargetId::MessageId(marker.id.as_ref().into()), + }), payload: Payload::ReadReceipt, }); }