diff --git a/crates/ruma-common/src/canonical_json.rs b/crates/ruma-common/src/canonical_json.rs index 2d01bd79..dda0b134 100644 --- a/crates/ruma-common/src/canonical_json.rs +++ b/crates/ruma-common/src/canonical_json.rs @@ -11,7 +11,10 @@ pub use self::value::{CanonicalJsonObject, CanonicalJsonValue}; use crate::RoomVersionId; #[cfg(feature = "events")] use crate::{ - events::room::redaction::{OriginalRoomRedactionEvent, OriginalSyncRoomRedactionEvent}, + events::room::redaction::{ + OriginalRoomRedactionEvent, OriginalSyncRoomRedactionEvent, RoomRedactionEvent, + SyncRoomRedactionEvent, + }, serde::Raw, }; @@ -150,6 +153,24 @@ impl TryFrom<&Raw> for RedactedBecause { } } +#[cfg(feature = "events")] +impl TryFrom<&Raw> for RedactedBecause { + type Error = serde_json::Error; + + fn try_from(value: &Raw) -> Result { + value.deserialize_as().map(Self) + } +} + +#[cfg(feature = "events")] +impl TryFrom<&Raw> for RedactedBecause { + type Error = serde_json::Error; + + fn try_from(value: &Raw) -> Result { + value.deserialize_as().map(Self) + } +} + /// Redacts an event using the rules specified in the Matrix client-server specification. /// /// This is part of the process of signing an event.