From b2b8265ded976e27f15f194594e505b2640f73de Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Wed, 11 Aug 2021 18:54:25 +0200 Subject: [PATCH] events: Split EncryptedEventContent in two --- crates/ruma-events/CHANGELOG.md | 3 +++ crates/ruma-events/src/room/encrypted.rs | 17 ++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/crates/ruma-events/CHANGELOG.md b/crates/ruma-events/CHANGELOG.md index 0b6a3c8e..c6d8cb7a 100644 --- a/crates/ruma-events/CHANGELOG.md +++ b/crates/ruma-events/CHANGELOG.md @@ -9,6 +9,9 @@ Breaking changes: validation * Remove unused `FromStrError` * Remove deprecated method `room::name::NameEventContent::name` +* Make `encrypted::EncryptedToDeviceEventContent` its own type instead of a type + alias for `EncryptedEventContent` + * It doesn't have the `relates_to` field `EncryptedEventContent` has * Upgrade dependencies # 0.24.0 diff --git a/crates/ruma-events/src/room/encrypted.rs b/crates/ruma-events/src/room/encrypted.rs index ced934d0..6db4871e 100644 --- a/crates/ruma-events/src/room/encrypted.rs +++ b/crates/ruma-events/src/room/encrypted.rs @@ -26,7 +26,7 @@ pub type EncryptedEvent = MessageEvent; #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.room.encrypted", kind = Message, kind = ToDevice)] pub struct EncryptedEventContent { - /// Encrypted event content + /// Algorithm-specific fields. #[serde(flatten)] pub scheme: EncryptedEventScheme, @@ -37,9 +37,6 @@ pub struct EncryptedEventContent { pub relates_to: Option, } -/// The to-device version of the payload for the `EncryptedEvent`. -pub type EncryptedToDeviceEventContent = EncryptedEventContent; - impl EncryptedEventContent { /// Creates a new `EncryptedEventContent` with the given scheme and relation. pub fn new(scheme: EncryptedEventScheme, relates_to: Option) -> Self { @@ -53,7 +50,17 @@ impl From for EncryptedEventContent { } } -/// The encryption scheme for `EncryptedEventContent` +/// The to-device content payload for `m.encrypted` events. +#[derive(Clone, Debug, Deserialize, Serialize, EventContent)] +#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] +#[ruma_event(type = "m.room.encrypted", kind = ToDevice)] +pub struct EncryptedToDeviceEventContent { + /// Algorithm-specific fields. + #[serde(flatten)] + pub scheme: EncryptedEventScheme, +} + +/// The encryption scheme for `EncryptedEventContent`. #[derive(Clone, Debug, Deserialize, Serialize)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[serde(tag = "algorithm")]