From feca893f1992420f8074bce1e1b21c846a83594b Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Tue, 8 Oct 2024 14:16:39 +0100 Subject: [PATCH] Inline `SyncTimelineEvent::set_raw` This is only used in one place, and is much better inlined anyway. --- crates/matrix-sdk-base/src/rooms/normal.rs | 7 ++++++- crates/matrix-sdk-common/src/deserialized_responses.rs | 5 ----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/matrix-sdk-base/src/rooms/normal.rs b/crates/matrix-sdk-base/src/rooms/normal.rs index 20ebc1b01d7..510bebdab0a 100644 --- a/crates/matrix-sdk-base/src/rooms/normal.rs +++ b/crates/matrix-sdk-base/src/rooms/normal.rs @@ -23,6 +23,8 @@ use std::{ use bitflags::bitflags; use eyeball::{SharedObservable, Subscriber}; use futures_util::{Stream, StreamExt}; +#[cfg(feature = "experimental-sliding-sync")] +use matrix_sdk_common::deserialized_responses::TimelineEventKind; #[cfg(all(feature = "e2e-encryption", feature = "experimental-sliding-sync"))] use matrix_sdk_common::ring_buffer::RingBuffer; #[cfg(feature = "experimental-sliding-sync")] @@ -1263,7 +1265,10 @@ impl RoomInfo { if latest_event.event_id().as_deref() == Some(redacts) { match apply_redaction(latest_event.event().raw(), _raw, room_version) { Some(redacted) => { - latest_event.event_mut().set_raw(redacted); + // Even if the original event was encrypted, redaction removes all its + // fields so it cannot possibly be successfully decrypted after redaction. + latest_event.event_mut().kind = + TimelineEventKind::PlainText { event: redacted }; debug!("Redacted latest event"); } None => { diff --git a/crates/matrix-sdk-common/src/deserialized_responses.rs b/crates/matrix-sdk-common/src/deserialized_responses.rs index c0717b28c96..6ef33dbfd20 100644 --- a/crates/matrix-sdk-common/src/deserialized_responses.rs +++ b/crates/matrix-sdk-common/src/deserialized_responses.rs @@ -357,11 +357,6 @@ impl SyncTimelineEvent { pub fn into_raw(self) -> Raw { self.kind.into_raw() } - - /// Replace the Matrix event within this event. Used to handle redaction. - pub fn set_raw(&mut self, event: Raw) { - self.kind = TimelineEventKind::PlainText { event }; - } } impl From> for SyncTimelineEvent {