sdk: Fix redaction regression

This commit is contained in:
Jonas Platte
2023-05-04 13:24:28 +02:00
committed by Jonas Platte
parent 749b57f30a
commit 443e729f5b
2 changed files with 8 additions and 5 deletions

View File

@@ -537,11 +537,15 @@ impl<'a> TimelineEventHandler<'a> {
// directly with the raw event timeline feature (not yet implemented).
update_timeline_item!(self, &redacts, "redaction", |event_item| {
let Some(remote_event_item) = event_item.as_remote() else {
error!("inconsistent state: reaction received on a non-remote event item");
error!("inconsistent state: redaction received on a non-remote event item");
return None;
};
Some(event_item.with_kind(remote_event_item.to_redacted()))
let mut event_item = event_item.to_owned();
event_item.content = TimelineItemContent::RedactedMessage;
event_item.kind = remote_event_item.without_reactions().into();
Some(event_item)
});
if self.result.items_updated == 0 {

View File

@@ -58,9 +58,8 @@ impl RemoteEventTimelineItem {
Self { reactions, ..self.clone() }
}
/// Clone the current event item, change its `content` to
/// [`TimelineItemContent::RedactedMessage`], and reset its `reactions`.
pub fn to_redacted(&self) -> Self {
/// Clone the current event item, and reset its `reactions`.
pub fn without_reactions(&self) -> Self {
Self { reactions: BundledReactions::default(), ..self.clone() }
}
}