Skip to content

Commit

Permalink
Inline SyncTimelineEvent::set_raw
Browse files Browse the repository at this point in the history
This is only used in one place, and is much better inlined anyway.
  • Loading branch information
richvdh committed Oct 9, 2024
1 parent 42f0d83 commit 9c64135
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
7 changes: 6 additions & 1 deletion crates/matrix-sdk-base/src/rooms/normal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -1285,7 +1287,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 => {
Expand Down
5 changes: 0 additions & 5 deletions crates/matrix-sdk-common/src/deserialized_responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,6 @@ impl SyncTimelineEvent {
pub fn into_raw(self) -> Raw<AnySyncTimelineEvent> {
self.kind.into_raw()
}

/// Replace the Matrix event within this event. Used to handle redaction.
pub fn set_raw(&mut self, event: Raw<AnySyncTimelineEvent>) {
self.kind = TimelineEventKind::PlainText { event };
}
}

impl From<Raw<AnySyncTimelineEvent>> for SyncTimelineEvent {
Expand Down

0 comments on commit 9c64135

Please sign in to comment.