Skip to content

Commit

Permalink
fix: Target messages for chat markers via StanzaId in MUC rooms (refs #…
Browse files Browse the repository at this point in the history
  • Loading branch information
nesium committed Mar 4, 2024
1 parent 3228ca5 commit 1d4a1a6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
}
Expand Down

0 comments on commit 1d4a1a6

Please sign in to comment.