events: Add support for bundled reference relations
According to MSC3267 / Matrix 1.5
This commit is contained in:
parent
1ecd7effc0
commit
583ee2cdfa
@ -50,6 +50,7 @@ Improvements:
|
|||||||
* `Ruleset::insert` to add or update user push rules
|
* `Ruleset::insert` to add or update user push rules
|
||||||
* `Ruleset::set_enabled` to change the enabled state of push rules
|
* `Ruleset::set_enabled` to change the enabled state of push rules
|
||||||
* `Ruleset::set_actions` to change the actions of push rules
|
* `Ruleset::set_actions` to change the actions of push rules
|
||||||
|
* Add support for bundled reference relations (MSC3267 / Matrix 1.5)
|
||||||
|
|
||||||
# 0.10.5
|
# 0.10.5
|
||||||
|
|
||||||
|
@ -131,6 +131,36 @@ impl BundledThread {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A bundled reference.
|
||||||
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
|
pub struct BundledReference {
|
||||||
|
/// The ID of the event referencing this event.
|
||||||
|
pub event_id: OwnedEventId,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl BundledReference {
|
||||||
|
/// Creates a new `BundledThread` with the given event ID.
|
||||||
|
pub fn new(event_id: OwnedEventId) -> Self {
|
||||||
|
Self { event_id }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A chunk of references.
|
||||||
|
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||||
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
|
pub struct ReferenceChunk {
|
||||||
|
/// A batch of bundled references.
|
||||||
|
pub chunk: Vec<BundledReference>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ReferenceChunk {
|
||||||
|
/// Creates a new `ReferenceChunk` with the given chunk.
|
||||||
|
pub fn new(chunk: Vec<BundledReference>) -> Self {
|
||||||
|
Self { chunk }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// [Bundled aggregations] of related child events.
|
/// [Bundled aggregations] of related child events.
|
||||||
///
|
///
|
||||||
/// [Bundled aggregations]: https://spec.matrix.org/v1.4/client-server-api/#aggregations
|
/// [Bundled aggregations]: https://spec.matrix.org/v1.4/client-server-api/#aggregations
|
||||||
@ -149,6 +179,10 @@ pub struct Relations {
|
|||||||
/// Thread relation.
|
/// Thread relation.
|
||||||
#[serde(rename = "m.thread")]
|
#[serde(rename = "m.thread")]
|
||||||
pub thread: Option<BundledThread>,
|
pub thread: Option<BundledThread>,
|
||||||
|
|
||||||
|
/// Reference relations.
|
||||||
|
#[serde(rename = "m.reference")]
|
||||||
|
pub reference: Option<ReferenceChunk>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Relations {
|
impl Relations {
|
||||||
@ -161,21 +195,22 @@ impl Relations {
|
|||||||
/// Relation types as defined in `rel_type` of an `m.relates_to` field.
|
/// Relation types as defined in `rel_type` of an `m.relates_to` field.
|
||||||
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
|
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
|
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
|
||||||
|
#[ruma_enum(rename_all = "m.snake_case")]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum RelationType {
|
pub enum RelationType {
|
||||||
/// `m.annotation`, an annotation, principally used by reactions.
|
/// `m.annotation`, an annotation, principally used by reactions.
|
||||||
#[cfg(feature = "unstable-msc2677")]
|
#[cfg(feature = "unstable-msc2677")]
|
||||||
#[ruma_enum(rename = "m.annotation")]
|
|
||||||
Annotation,
|
Annotation,
|
||||||
|
|
||||||
/// `m.replace`, a replacement.
|
/// `m.replace`, a replacement.
|
||||||
#[ruma_enum(rename = "m.replace")]
|
|
||||||
Replacement,
|
Replacement,
|
||||||
|
|
||||||
/// `m.thread`, a participant to a thread.
|
/// `m.thread`, a participant to a thread.
|
||||||
#[ruma_enum(rename = "m.thread")]
|
|
||||||
Thread,
|
Thread,
|
||||||
|
|
||||||
|
/// `m.reference`, a reference to another event.
|
||||||
|
Reference,
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
_Custom(PrivOwnedStr),
|
_Custom(PrivOwnedStr),
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user