events: Stabilize annotations and reactions
This commit is contained in:
parent
ce30aeb775
commit
2d697fcc95
@ -36,6 +36,7 @@ Improvements:
|
|||||||
- `user_can_trigger_room_notification`
|
- `user_can_trigger_room_notification`
|
||||||
- Add `MessageType::sanitize` behind the `unstable-sanitize` feature
|
- Add `MessageType::sanitize` behind the `unstable-sanitize` feature
|
||||||
- Add `MatrixVersion::V1_7`
|
- Add `MatrixVersion::V1_7`
|
||||||
|
- Stabilize support for annotations and reactions (MSC2677 / Matrix 1.7)
|
||||||
|
|
||||||
# 0.11.3
|
# 0.11.3
|
||||||
|
|
||||||
|
@ -30,7 +30,6 @@ rand = ["dep:rand", "dep:uuid"]
|
|||||||
unstable-exhaustive-types = []
|
unstable-exhaustive-types = []
|
||||||
unstable-msc1767 = []
|
unstable-msc1767 = []
|
||||||
unstable-msc2448 = []
|
unstable-msc2448 = []
|
||||||
unstable-msc2677 = []
|
|
||||||
unstable-msc2746 = []
|
unstable-msc2746 = []
|
||||||
unstable-msc2747 = []
|
unstable-msc2747 = []
|
||||||
unstable-msc2870 = []
|
unstable-msc2870 = []
|
||||||
|
@ -149,7 +149,6 @@ pub mod policy;
|
|||||||
pub mod poll;
|
pub mod poll;
|
||||||
pub mod presence;
|
pub mod presence;
|
||||||
pub mod push_rules;
|
pub mod push_rules;
|
||||||
#[cfg(feature = "unstable-msc2677")]
|
|
||||||
pub mod reaction;
|
pub mod reaction;
|
||||||
pub mod receipt;
|
pub mod receipt;
|
||||||
pub mod relation;
|
pub mod relation;
|
||||||
|
@ -79,7 +79,6 @@ event_enum! {
|
|||||||
#[cfg(feature = "unstable-msc3381")]
|
#[cfg(feature = "unstable-msc3381")]
|
||||||
#[ruma_enum(alias = "m.poll.end")]
|
#[ruma_enum(alias = "m.poll.end")]
|
||||||
"org.matrix.msc3381.v2.poll.end" => super::poll::end,
|
"org.matrix.msc3381.v2.poll.end" => super::poll::end,
|
||||||
#[cfg(feature = "unstable-msc2677")]
|
|
||||||
"m.reaction" => super::reaction,
|
"m.reaction" => super::reaction,
|
||||||
"m.room.encrypted" => super::room::encrypted,
|
"m.room.encrypted" => super::room::encrypted,
|
||||||
"m.room.message" => super::room::message,
|
"m.room.message" => super::room::message,
|
||||||
@ -313,7 +312,6 @@ impl AnyMessageLikeEventContent {
|
|||||||
| Self::KeyVerificationDone(KeyVerificationDoneEventContent { relates_to, .. }) => {
|
| Self::KeyVerificationDone(KeyVerificationDoneEventContent { relates_to, .. }) => {
|
||||||
Some(encrypted::Relation::Reference(relates_to.clone()))
|
Some(encrypted::Relation::Reference(relates_to.clone()))
|
||||||
},
|
},
|
||||||
#[cfg(feature = "unstable-msc2677")]
|
|
||||||
Self::Reaction(ev) => Some(encrypted::Relation::Annotation(ev.relates_to.clone())),
|
Self::Reaction(ev) => Some(encrypted::Relation::Annotation(ev.relates_to.clone())),
|
||||||
Self::RoomEncrypted(ev) => ev.relates_to.clone(),
|
Self::RoomEncrypted(ev) => ev.relates_to.clone(),
|
||||||
Self::RoomMessage(ev) => ev.relates_to.clone().map(Into::into),
|
Self::RoomMessage(ev) => ev.relates_to.clone().map(Into::into),
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
//! Types for the `m.reaction` event.
|
//! Types for the [`m.reaction`] event.
|
||||||
|
//!
|
||||||
|
//! [`m.reaction`]: https://spec.matrix.org/latest/client-server-api/#mreaction
|
||||||
|
|
||||||
use ruma_macros::EventContent;
|
use ruma_macros::EventContent;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
@ -34,9 +34,8 @@ impl InReplyTo {
|
|||||||
|
|
||||||
/// An [annotation] for an event.
|
/// An [annotation] for an event.
|
||||||
///
|
///
|
||||||
/// [annotation]: https://github.com/matrix-org/matrix-spec-proposals/pull/2677
|
/// [annotation]: https://spec.matrix.org/latest/client-server-api/#event-annotations-and-reactions
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
#[cfg(feature = "unstable-msc2677")]
|
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
#[serde(tag = "rel_type", rename = "m.annotation")]
|
#[serde(tag = "rel_type", rename = "m.annotation")]
|
||||||
pub struct Annotation {
|
pub struct Annotation {
|
||||||
@ -52,7 +51,6 @@ pub struct Annotation {
|
|||||||
pub key: String,
|
pub key: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "unstable-msc2677")]
|
|
||||||
impl Annotation {
|
impl Annotation {
|
||||||
/// Creates a new `Annotation` with the given event ID and key.
|
/// Creates a new `Annotation` with the given event ID and key.
|
||||||
pub fn new(event_id: OwnedEventId, key: String) -> Self {
|
pub fn new(event_id: OwnedEventId, key: String) -> Self {
|
||||||
@ -290,7 +288,6 @@ impl BundledStateRelations {
|
|||||||
#[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")]
|
|
||||||
Annotation,
|
Annotation,
|
||||||
|
|
||||||
/// `m.replace`, a replacement.
|
/// `m.replace`, a replacement.
|
||||||
|
@ -9,10 +9,8 @@ use ruma_macros::EventContent;
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use super::message;
|
use super::message;
|
||||||
#[cfg(feature = "unstable-msc2677")]
|
|
||||||
use crate::events::relation::Annotation;
|
|
||||||
use crate::{
|
use crate::{
|
||||||
events::relation::{InReplyTo, Reference, Thread},
|
events::relation::{Annotation, InReplyTo, Reference, Thread},
|
||||||
OwnedDeviceId, OwnedEventId,
|
OwnedDeviceId, OwnedEventId,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -106,7 +104,6 @@ pub enum Relation {
|
|||||||
Reference(Reference),
|
Reference(Reference),
|
||||||
|
|
||||||
/// An annotation to an event.
|
/// An annotation to an event.
|
||||||
#[cfg(feature = "unstable-msc2677")]
|
|
||||||
Annotation(Annotation),
|
Annotation(Annotation),
|
||||||
|
|
||||||
/// An event that belongs to a thread.
|
/// An event that belongs to a thread.
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||||
|
|
||||||
#[cfg(feature = "unstable-msc2677")]
|
use super::{Annotation, InReplyTo, Reference, Relation, Replacement, Thread};
|
||||||
use super::Annotation;
|
|
||||||
use super::{InReplyTo, Reference, Relation, Replacement, Thread};
|
|
||||||
use crate::OwnedEventId;
|
use crate::OwnedEventId;
|
||||||
|
|
||||||
pub(crate) fn deserialize_relation<'de, D>(deserializer: D) -> Result<Option<Relation>, D::Error>
|
pub(crate) fn deserialize_relation<'de, D>(deserializer: D) -> Result<Option<Relation>, D::Error>
|
||||||
@ -23,7 +21,6 @@ where
|
|||||||
Some(Relation::Reply { in_reply_to })
|
Some(Relation::Reply { in_reply_to })
|
||||||
} else {
|
} else {
|
||||||
ev.relates_to.relation.map(|relation| match relation {
|
ev.relates_to.relation.map(|relation| match relation {
|
||||||
#[cfg(feature = "unstable-msc2677")]
|
|
||||||
RelationJsonRepr::Annotation(a) => Relation::Annotation(a),
|
RelationJsonRepr::Annotation(a) => Relation::Annotation(a),
|
||||||
RelationJsonRepr::Reference(r) => Relation::Reference(r),
|
RelationJsonRepr::Reference(r) => Relation::Reference(r),
|
||||||
RelationJsonRepr::Replacement(Replacement { event_id }) => {
|
RelationJsonRepr::Replacement(Replacement { event_id }) => {
|
||||||
@ -48,7 +45,6 @@ impl Serialize for Relation {
|
|||||||
{
|
{
|
||||||
#[allow(clippy::needless_update)]
|
#[allow(clippy::needless_update)]
|
||||||
let relates_to = match self {
|
let relates_to = match self {
|
||||||
#[cfg(feature = "unstable-msc2677")]
|
|
||||||
Relation::Annotation(r) => RelatesToJsonRepr {
|
Relation::Annotation(r) => RelatesToJsonRepr {
|
||||||
relation: Some(RelationJsonRepr::Annotation(r.clone())),
|
relation: Some(RelationJsonRepr::Annotation(r.clone())),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
@ -137,7 +133,6 @@ struct ThreadUnstableJsonRepr {
|
|||||||
#[serde(tag = "rel_type")]
|
#[serde(tag = "rel_type")]
|
||||||
enum RelationJsonRepr {
|
enum RelationJsonRepr {
|
||||||
/// An annotation to an event.
|
/// An annotation to an event.
|
||||||
#[cfg(feature = "unstable-msc2677")]
|
|
||||||
#[serde(rename = "m.annotation")]
|
#[serde(rename = "m.annotation")]
|
||||||
Annotation(Annotation),
|
Annotation(Annotation),
|
||||||
|
|
||||||
|
@ -30,9 +30,8 @@ impl Ruleset {
|
|||||||
ConditionalPushRule::contains_display_name(),
|
ConditionalPushRule::contains_display_name(),
|
||||||
ConditionalPushRule::roomnotif(),
|
ConditionalPushRule::roomnotif(),
|
||||||
ConditionalPushRule::tombstone(),
|
ConditionalPushRule::tombstone(),
|
||||||
ConditionalPushRule::server_acl(),
|
|
||||||
#[cfg(feature = "unstable-msc2677")]
|
|
||||||
ConditionalPushRule::reaction(),
|
ConditionalPushRule::reaction(),
|
||||||
|
ConditionalPushRule::server_acl(),
|
||||||
]
|
]
|
||||||
.into(),
|
.into(),
|
||||||
underride: [
|
underride: [
|
||||||
@ -227,9 +226,9 @@ impl ConditionalPushRule {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Matches emoji reactions to a message
|
/// Matches [reactions] to a message.
|
||||||
/// MSC2677: Annotations and Reactions
|
///
|
||||||
#[cfg(feature = "unstable-msc2677")]
|
/// [reactions]: https://spec.matrix.org/latest/client-server-api/#event-annotations-and-reactions
|
||||||
pub fn reaction() -> Self {
|
pub fn reaction() -> Self {
|
||||||
Self {
|
Self {
|
||||||
actions: vec![],
|
actions: vec![],
|
||||||
@ -469,7 +468,6 @@ pub enum PredefinedOverrideRuleId {
|
|||||||
RoomServerAcl,
|
RoomServerAcl,
|
||||||
|
|
||||||
/// `.m.rule.reaction`
|
/// `.m.rule.reaction`
|
||||||
#[cfg(feature = "unstable-msc2677")]
|
|
||||||
Reaction,
|
Reaction,
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
|
@ -386,7 +386,6 @@ fn content_thread_deserialization() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "unstable-msc2677")]
|
|
||||||
fn content_annotation_serialization() {
|
fn content_annotation_serialization() {
|
||||||
use ruma_common::events::relation::Annotation;
|
use ruma_common::events::relation::Annotation;
|
||||||
|
|
||||||
@ -421,7 +420,6 @@ fn content_annotation_serialization() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "unstable-msc2677")]
|
|
||||||
fn content_annotation_deserialization() {
|
fn content_annotation_deserialization() {
|
||||||
let json = json!({
|
let json = json!({
|
||||||
"algorithm": "m.megolm.v1.aes-sha2",
|
"algorithm": "m.megolm.v1.aes-sha2",
|
||||||
|
@ -157,7 +157,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-msc2677 = ["ruma-common/unstable-msc2677"]
|
|
||||||
unstable-msc2746 = ["ruma-common/unstable-msc2746"]
|
unstable-msc2746 = ["ruma-common/unstable-msc2746"]
|
||||||
unstable-msc2747 = ["ruma-common/unstable-msc2747"]
|
unstable-msc2747 = ["ruma-common/unstable-msc2747"]
|
||||||
unstable-msc2870 = ["ruma-common/unstable-msc2870"]
|
unstable-msc2870 = ["ruma-common/unstable-msc2870"]
|
||||||
@ -203,7 +202,6 @@ __ci = [
|
|||||||
"unstable-msc2448",
|
"unstable-msc2448",
|
||||||
"unstable-msc2654",
|
"unstable-msc2654",
|
||||||
"unstable-msc2666",
|
"unstable-msc2666",
|
||||||
"unstable-msc2677",
|
|
||||||
"unstable-msc2746",
|
"unstable-msc2746",
|
||||||
"unstable-msc2747",
|
"unstable-msc2747",
|
||||||
"unstable-msc2870",
|
"unstable-msc2870",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user