common: Add replacement to Relations
This commit is contained in:
parent
260dfeb100
commit
f0c8703ee5
@ -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<EventId>,
|
||||
|
||||
/// The user ID of the sender of the latest replacement.
|
||||
pub sender: Box<UserId>,
|
||||
|
||||
/// Timestamp in milliseconds on originating homeserver when the latest replacement was sent.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub origin_server_ts: Option<MilliSecondsSinceUnixEpoch>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "unstable-msc2676")]
|
||||
impl BundledReplacement {
|
||||
/// Creates a new `BundledReplacement` with the given event ID and sender.
|
||||
pub fn new(event_id: Box<EventId>, sender: Box<UserId>) -> 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<AnnotationChunk>,
|
||||
|
||||
/// Replacement relation.
|
||||
#[cfg(feature = "unstable-msc2676")]
|
||||
#[serde(rename = "m.replace")]
|
||||
pub replace: Option<BundledReplacement>,
|
||||
}
|
||||
|
||||
impl Relations {
|
||||
|
Loading…
x
Reference in New Issue
Block a user