events: Remove reaction bundling

It was removed from the MSC.
https://github.com/matrix-org/matrix-spec-proposals/pull/2677
This commit is contained in:
Jonas Platte 2023-02-28 20:01:04 +01:00
parent 57083ef3f8
commit f9a40e137e
No known key found for this signature in database
GPG Key ID: AAA7A61F696C3E0C

View File

@ -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<MilliSecondsSinceUnixEpoch>,
/// 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<BundledAnnotation>,
/// Token to receive the next annotation batch.
#[serde(skip_serializing_if = "Option::is_none")]
pub next_batch: Option<String>,
}
#[cfg(feature = "unstable-msc2677")]
impl AnnotationChunk {
/// Creates a new `AnnotationChunk` with the given chunk and next batch token.
pub fn new(chunk: Vec<BundledAnnotation>, next_batch: Option<String>) -> 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<Box<AnnotationChunk>>,
/// Replacement relation.
#[serde(rename = "m.replace", skip_serializing_if = "Option::is_none")]
pub replace: Option<Box<BundledReplacement>>,
@ -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()
}
}