diff --git a/crates/ruma-common/src/events/relation.rs b/crates/ruma-common/src/events/relation.rs index 22aecaff..519e6dea 100644 --- a/crates/ruma-common/src/events/relation.rs +++ b/crates/ruma-common/src/events/relation.rs @@ -5,7 +5,7 @@ use std::fmt::Debug; use js_int::UInt; use serde::{Deserialize, Serialize}; -use crate::MilliSecondsSinceUnixEpoch; +use crate::{EventId, MilliSecondsSinceUnixEpoch, UserId}; /// Summary of all reactions with the given key to an event. #[derive(Clone, Debug, Default, Deserialize, PartialEq, Eq, Serialize)] @@ -67,6 +67,30 @@ impl AnnotationChunk { } } +/// A bundled replacement. +#[derive(Clone, Debug, Deserialize, Serialize)] +#[cfg(feature = "unstable-msc2676")] +#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] +pub struct BundledReplacement { + /// The ID of the replacing event. + pub event_id: Box, + + /// The user ID of the sender of the latest replacement. + pub sender: Box, + + /// Timestamp in milliseconds on originating homeserver when the latest replacement was sent. + #[serde(skip_serializing_if = "Option::is_none")] + pub origin_server_ts: Option, +} + +#[cfg(feature = "unstable-msc2676")] +impl BundledReplacement { + /// Creates a new `BundledReplacement` with the given event ID and sender. + pub fn new(event_id: Box, sender: Box) -> Self { + Self { event_id, sender, origin_server_ts: None } + } +} + /// Precompiled list of relations to this event grouped by relation type. #[derive(Clone, Debug, Default, Deserialize, Serialize)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] @@ -75,6 +99,11 @@ pub struct Relations { #[cfg(feature = "unstable-msc2677")] #[serde(rename = "m.annotation")] pub annotation: Option, + + /// Replacement relation. + #[cfg(feature = "unstable-msc2676")] + #[serde(rename = "m.replace")] + pub replace: Option, } impl Relations {