events: Stabilize MSC2675
This commit is contained in:
parent
a077c4ea77
commit
80a8dcf28a
@ -29,6 +29,7 @@ Improvements:
|
|||||||
* Add support for knocking in `events::room::member::MembershipChange`
|
* Add support for knocking in `events::room::member::MembershipChange`
|
||||||
* Add `MatrixVersion::V1_3`
|
* Add `MatrixVersion::V1_3`
|
||||||
* Deprecate the `sender_key` and `device_id` fields for encrypted events (MSC3700)
|
* Deprecate the `sender_key` and `device_id` fields for encrypted events (MSC3700)
|
||||||
|
* Move the `relations` field of `events::unsigned` types out of `unstable-msc2675`
|
||||||
|
|
||||||
# 0.9.2
|
# 0.9.2
|
||||||
|
|
||||||
|
@ -34,7 +34,6 @@ unstable-pdu = []
|
|||||||
unstable-pre-spec = []
|
unstable-pre-spec = []
|
||||||
unstable-msc1767 = []
|
unstable-msc1767 = []
|
||||||
unstable-msc2448 = []
|
unstable-msc2448 = []
|
||||||
unstable-msc2675 = []
|
|
||||||
unstable-msc2676 = []
|
unstable-msc2676 = []
|
||||||
unstable-msc2677 = []
|
unstable-msc2677 = []
|
||||||
unstable-msc2746 = []
|
unstable-msc2746 = []
|
||||||
|
@ -153,7 +153,6 @@ pub mod push_rules;
|
|||||||
#[cfg(feature = "unstable-msc2677")]
|
#[cfg(feature = "unstable-msc2677")]
|
||||||
pub mod reaction;
|
pub mod reaction;
|
||||||
pub mod receipt;
|
pub mod receipt;
|
||||||
#[cfg(feature = "unstable-msc2675")]
|
|
||||||
pub mod relation;
|
pub mod relation;
|
||||||
pub mod room;
|
pub mod room;
|
||||||
pub mod room_key;
|
pub mod room_key;
|
||||||
@ -169,12 +168,11 @@ pub mod video;
|
|||||||
#[cfg(feature = "unstable-msc3245")]
|
#[cfg(feature = "unstable-msc3245")]
|
||||||
pub mod voice;
|
pub mod voice;
|
||||||
|
|
||||||
#[cfg(feature = "unstable-msc2675")]
|
|
||||||
pub use self::relation::Relations;
|
|
||||||
pub use self::{
|
pub use self::{
|
||||||
content::*,
|
content::*,
|
||||||
enums::*,
|
enums::*,
|
||||||
kinds::*,
|
kinds::*,
|
||||||
|
relation::Relations,
|
||||||
state_key::EmptyStateKey,
|
state_key::EmptyStateKey,
|
||||||
unsigned::{MessageLikeUnsigned, RedactedUnsigned, StateUnsigned},
|
unsigned::{MessageLikeUnsigned, RedactedUnsigned, StateUnsigned},
|
||||||
};
|
};
|
||||||
|
@ -1,15 +1,22 @@
|
|||||||
//! Types describing event relations after MSC 2674, 2675, 2676, 2677.
|
//! Types describing [relationships between events].
|
||||||
|
//!
|
||||||
|
//! [relationships between events]: https://spec.matrix.org/v1.3/client-server-api/#forming-relationships-between-events
|
||||||
|
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
|
|
||||||
|
#[cfg(any(feature = "unstable-msc2677", feature = "unstable-msc3440"))]
|
||||||
use js_int::UInt;
|
use js_int::UInt;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[cfg(feature = "unstable-msc3440")]
|
||||||
use super::AnySyncMessageLikeEvent;
|
use super::AnySyncMessageLikeEvent;
|
||||||
use crate::{
|
#[cfg(feature = "unstable-msc3440")]
|
||||||
serde::{Raw, StringEnum},
|
use crate::serde::Raw;
|
||||||
MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedUserId, PrivOwnedStr,
|
#[cfg(feature = "unstable-msc2677")]
|
||||||
};
|
use crate::MilliSecondsSinceUnixEpoch;
|
||||||
|
use crate::{serde::StringEnum, PrivOwnedStr};
|
||||||
|
#[cfg(feature = "unstable-msc2676")]
|
||||||
|
use crate::{OwnedEventId, OwnedUserId};
|
||||||
|
|
||||||
/// Summary of all annotations to an event with the given key and type.
|
/// Summary of all annotations to an event with the given key and type.
|
||||||
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize)]
|
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize)]
|
||||||
@ -130,7 +137,9 @@ impl BundledThread {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Precompiled list of relations to this event grouped by relation type.
|
/// [Bundled aggregations] of related child events.
|
||||||
|
///
|
||||||
|
/// [Bundled aggregations]: https://spec.matrix.org/v1.3/client-server-api/#aggregations
|
||||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
pub struct Relations {
|
pub struct Relations {
|
||||||
@ -160,7 +169,6 @@ 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)]
|
||||||
#[cfg(any(feature = "unstable-msc3440", feature = "unstable-msc2675"))]
|
|
||||||
#[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.
|
||||||
|
@ -2,9 +2,7 @@ use js_int::Int;
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::{from_str as from_json_str, value::RawValue as RawJsonValue};
|
use serde_json::{from_str as from_json_str, value::RawValue as RawJsonValue};
|
||||||
|
|
||||||
#[cfg(feature = "unstable-msc2675")]
|
use super::{relation::Relations, room::redaction::SyncRoomRedactionEvent, StateEventContent};
|
||||||
use super::relation::Relations;
|
|
||||||
use super::{room::redaction::SyncRoomRedactionEvent, StateEventContent};
|
|
||||||
use crate::{serde::Raw, OwnedTransactionId};
|
use crate::{serde::Raw, OwnedTransactionId};
|
||||||
|
|
||||||
/// Extra information about a message event that is not incorporated into the event's hash.
|
/// Extra information about a message event that is not incorporated into the event's hash.
|
||||||
@ -24,8 +22,9 @@ pub struct MessageLikeUnsigned {
|
|||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub transaction_id: Option<OwnedTransactionId>,
|
pub transaction_id: Option<OwnedTransactionId>,
|
||||||
|
|
||||||
/// Server-compiled information from other events relating to this event.
|
/// [Bundled aggregations] of related child events.
|
||||||
#[cfg(feature = "unstable-msc2675")]
|
///
|
||||||
|
/// [Bundled aggregations]: https://spec.matrix.org/v1.3/client-server-api/#aggregations
|
||||||
#[serde(rename = "m.relations", skip_serializing_if = "Option::is_none")]
|
#[serde(rename = "m.relations", skip_serializing_if = "Option::is_none")]
|
||||||
pub relations: Option<Relations>,
|
pub relations: Option<Relations>,
|
||||||
}
|
}
|
||||||
@ -42,16 +41,8 @@ impl MessageLikeUnsigned {
|
|||||||
/// events. Do not use it to determine whether an incoming `unsigned` field was present - it
|
/// events. Do not use it to determine whether an incoming `unsigned` field was present - it
|
||||||
/// could still have been present but contained none of the known fields.
|
/// could still have been present but contained none of the known fields.
|
||||||
pub fn is_empty(&self) -> bool {
|
pub fn is_empty(&self) -> bool {
|
||||||
#[cfg(not(feature = "unstable-msc2675"))]
|
|
||||||
{
|
|
||||||
self.age.is_none() && self.transaction_id.is_none()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "unstable-msc2675")]
|
|
||||||
{
|
|
||||||
self.age.is_none() && self.transaction_id.is_none() && self.relations.is_none()
|
self.age.is_none() && self.transaction_id.is_none() && self.relations.is_none()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extra information about a state event that is not incorporated into the event's hash.
|
/// Extra information about a state event that is not incorporated into the event's hash.
|
||||||
@ -75,8 +66,9 @@ pub struct StateUnsigned<C: StateEventContent> {
|
|||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub prev_content: Option<C>,
|
pub prev_content: Option<C>,
|
||||||
|
|
||||||
/// Server-compiled information from other events relating to this event.
|
/// [Bundled aggregations] of related child events.
|
||||||
#[cfg(feature = "unstable-msc2675")]
|
///
|
||||||
|
/// [Bundled aggregations]: https://spec.matrix.org/v1.3/client-server-api/#aggregations
|
||||||
#[serde(rename = "m.relations", skip_serializing_if = "Option::is_none")]
|
#[serde(rename = "m.relations", skip_serializing_if = "Option::is_none")]
|
||||||
pub relations: Option<Relations>,
|
pub relations: Option<Relations>,
|
||||||
}
|
}
|
||||||
@ -84,13 +76,7 @@ pub struct StateUnsigned<C: StateEventContent> {
|
|||||||
impl<C: StateEventContent> StateUnsigned<C> {
|
impl<C: StateEventContent> StateUnsigned<C> {
|
||||||
/// Create a new `Unsigned` with fields set to `None`.
|
/// Create a new `Unsigned` with fields set to `None`.
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self { age: None, transaction_id: None, prev_content: None, relations: None }
|
||||||
age: None,
|
|
||||||
transaction_id: None,
|
|
||||||
prev_content: None,
|
|
||||||
#[cfg(feature = "unstable-msc2675")]
|
|
||||||
relations: None,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Whether this unsigned data is empty (all fields are `None`).
|
/// Whether this unsigned data is empty (all fields are `None`).
|
||||||
@ -99,19 +85,11 @@ impl<C: StateEventContent> StateUnsigned<C> {
|
|||||||
/// events. Do not use it to determine whether an incoming `unsigned` field was present - it
|
/// events. Do not use it to determine whether an incoming `unsigned` field was present - it
|
||||||
/// could still have been present but contained none of the known fields.
|
/// could still have been present but contained none of the known fields.
|
||||||
pub fn is_empty(&self) -> bool {
|
pub fn is_empty(&self) -> bool {
|
||||||
#[cfg(not(feature = "unstable-msc2675"))]
|
|
||||||
{
|
|
||||||
self.age.is_none() && self.transaction_id.is_none() && self.prev_content.is_none()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "unstable-msc2675")]
|
|
||||||
{
|
|
||||||
self.age.is_none()
|
self.age.is_none()
|
||||||
&& self.transaction_id.is_none()
|
&& self.transaction_id.is_none()
|
||||||
&& self.prev_content.is_none()
|
&& self.prev_content.is_none()
|
||||||
&& self.relations.is_none()
|
&& self.relations.is_none()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper functions for proc-macro code.
|
/// Helper functions for proc-macro code.
|
||||||
@ -128,7 +106,6 @@ impl<C: StateEventContent> StateUnsigned<C> {
|
|||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
transaction_id: Option<OwnedTransactionId>,
|
transaction_id: Option<OwnedTransactionId>,
|
||||||
prev_content: Option<Raw<C>>,
|
prev_content: Option<Raw<C>>,
|
||||||
#[cfg(feature = "unstable-msc2675")]
|
|
||||||
#[serde(rename = "m.relations", skip_serializing_if = "Option::is_none")]
|
#[serde(rename = "m.relations", skip_serializing_if = "Option::is_none")]
|
||||||
relations: Option<Relations>,
|
relations: Option<Relations>,
|
||||||
}
|
}
|
||||||
@ -140,7 +117,6 @@ impl<C: StateEventContent> StateUnsigned<C> {
|
|||||||
Ok(Self {
|
Ok(Self {
|
||||||
age: raw.age,
|
age: raw.age,
|
||||||
transaction_id: raw.transaction_id,
|
transaction_id: raw.transaction_id,
|
||||||
#[cfg(feature = "unstable-msc2675")]
|
|
||||||
relations: raw.relations,
|
relations: raw.relations,
|
||||||
prev_content,
|
prev_content,
|
||||||
})
|
})
|
||||||
@ -154,7 +130,6 @@ impl<C: StateEventContent> StateUnsigned<C> {
|
|||||||
age: self.age,
|
age: self.age,
|
||||||
transaction_id: self.transaction_id.clone(),
|
transaction_id: self.transaction_id.clone(),
|
||||||
prev_content: self.prev_content.as_ref().map(f),
|
prev_content: self.prev_content.as_ref().map(f),
|
||||||
#[cfg(feature = "unstable-msc2675")]
|
|
||||||
relations: self.relations.clone(),
|
relations: self.relations.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,9 +125,6 @@ unstable-msc2448 = [
|
|||||||
]
|
]
|
||||||
unstable-msc2654 = ["ruma-client-api?/unstable-msc2654"]
|
unstable-msc2654 = ["ruma-client-api?/unstable-msc2654"]
|
||||||
unstable-msc2666 = ["ruma-client-api?/unstable-msc2666"]
|
unstable-msc2666 = ["ruma-client-api?/unstable-msc2666"]
|
||||||
unstable-msc2675 = [
|
|
||||||
"ruma-common/unstable-msc2675",
|
|
||||||
]
|
|
||||||
unstable-msc2676 = [
|
unstable-msc2676 = [
|
||||||
"ruma-client-api?/unstable-msc2676",
|
"ruma-client-api?/unstable-msc2676",
|
||||||
"ruma-common/unstable-msc2676",
|
"ruma-common/unstable-msc2676",
|
||||||
@ -165,7 +162,6 @@ __ci = [
|
|||||||
"unstable-msc2448",
|
"unstable-msc2448",
|
||||||
"unstable-msc2666",
|
"unstable-msc2666",
|
||||||
"unstable-msc2654",
|
"unstable-msc2654",
|
||||||
"unstable-msc2675",
|
|
||||||
"unstable-msc2676",
|
"unstable-msc2676",
|
||||||
"unstable-msc2677",
|
"unstable-msc2677",
|
||||||
"unstable-msc2746",
|
"unstable-msc2746",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user