From f9a40e137ee258fd374726f0bc91db9b3d84c7e1 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Tue, 28 Feb 2023 20:01:04 +0100 Subject: [PATCH] events: Remove reaction bundling It was removed from the MSC. https://github.com/matrix-org/matrix-spec-proposals/pull/2677 --- crates/ruma-common/src/events/relation.rs | 90 +---------------------- 1 file changed, 2 insertions(+), 88 deletions(-) diff --git a/crates/ruma-common/src/events/relation.rs b/crates/ruma-common/src/events/relation.rs index 78ef6e01..7abb53c3 100644 --- a/crates/ruma-common/src/events/relation.rs +++ b/crates/ruma-common/src/events/relation.rs @@ -58,74 +58,6 @@ impl Annotation { } } -/// Summary of all annotations to an event with the given key and type. -#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize)] -#[cfg(feature = "unstable-msc2677")] -#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] -pub struct BundledAnnotation { - /// The type of the annotation. - #[serde(rename = "type")] - pub annotation_type: AnnotationType, - - /// The key used for the annotation. - pub key: String, - - /// Time of the bundled annotation being compiled on the server. - #[serde(skip_serializing_if = "Option::is_none")] - pub origin_server_ts: Option, - - /// Number of annotations. - pub count: UInt, -} - -#[cfg(feature = "unstable-msc2677")] -impl BundledAnnotation { - /// Creates a new `BundledAnnotation` with the given type, key and count. - pub fn new(annotation_type: AnnotationType, key: String, count: UInt) -> Self { - Self { annotation_type, key, count, origin_server_ts: None } - } - - /// Creates a new `BundledAnnotation` for a reaction with the given key and count. - pub fn reaction(key: String, count: UInt) -> Self { - Self::new(AnnotationType::Reaction, key, count) - } -} - -/// Type of annotation. -#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] -#[derive(Clone, PartialEq, Eq, StringEnum)] -#[cfg(feature = "unstable-msc2677")] -#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] -pub enum AnnotationType { - /// A reaction. - #[ruma_enum(rename = "m.reaction")] - Reaction, - - #[doc(hidden)] - _Custom(PrivOwnedStr), -} - -/// The first chunk of annotations with a token for loading more. -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[cfg(feature = "unstable-msc2677")] -#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] -pub struct AnnotationChunk { - /// The first batch of bundled annotations. - pub chunk: Vec, - - /// Token to receive the next annotation batch. - #[serde(skip_serializing_if = "Option::is_none")] - pub next_batch: Option, -} - -#[cfg(feature = "unstable-msc2677")] -impl AnnotationChunk { - /// Creates a new `AnnotationChunk` with the given chunk and next batch token. - pub fn new(chunk: Vec, next_batch: Option) -> Self { - Self { chunk, next_batch } - } -} - /// A bundled replacement. #[derive(Clone, Debug, Deserialize, Serialize)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] @@ -292,11 +224,6 @@ impl ReferenceChunk { #[derive(Clone, Debug, Default, Deserialize, Serialize)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] pub struct BundledRelations { - /// Annotation relations. - #[cfg(feature = "unstable-msc2677")] - #[serde(rename = "m.annotation", skip_serializing_if = "Option::is_none")] - pub annotation: Option>, - /// Replacement relation. #[serde(rename = "m.replace", skip_serializing_if = "Option::is_none")] pub replace: Option>, @@ -313,25 +240,12 @@ pub struct BundledRelations { impl BundledRelations { /// Creates a new empty `BundledRelations`. pub const fn new() -> Self { - Self { - #[cfg(feature = "unstable-msc2677")] - annotation: None, - replace: None, - thread: None, - reference: None, - } + Self { replace: None, thread: None, reference: None } } /// Returns `true` if all fields are empty. pub fn is_empty(&self) -> bool { - #[cfg(not(feature = "unstable-msc2677"))] - return self.replace.is_none() && self.thread.is_none() && self.reference.is_none(); - - #[cfg(feature = "unstable-msc2677")] - return self.annotation.is_none() - && self.replace.is_none() - && self.thread.is_none() - && self.reference.is_none(); + self.replace.is_none() && self.thread.is_none() && self.reference.is_none() } }