events: Feature-gate reactions
and make relationships module public. The re-export idea doesn't make sense with annotations being used in both reactions and messages.
This commit is contained in:
parent
b7e15efe43
commit
c322bd4d1e
@ -36,6 +36,7 @@ event_enum! {
|
|||||||
"m.call.invite",
|
"m.call.invite",
|
||||||
"m.call.hangup",
|
"m.call.hangup",
|
||||||
"m.call.candidates",
|
"m.call.candidates",
|
||||||
|
#[cfg(feature = "unstable-pre-spec")]
|
||||||
"m.reaction",
|
"m.reaction",
|
||||||
"m.room.encrypted",
|
"m.room.encrypted",
|
||||||
"m.room.message",
|
"m.room.message",
|
||||||
|
@ -170,6 +170,7 @@ pub mod pdu;
|
|||||||
pub mod policy;
|
pub mod policy;
|
||||||
pub mod presence;
|
pub mod presence;
|
||||||
pub mod push_rules;
|
pub mod push_rules;
|
||||||
|
#[cfg(feature = "unstable-pre-spec")]
|
||||||
pub mod reaction;
|
pub mod reaction;
|
||||||
pub mod receipt;
|
pub mod receipt;
|
||||||
pub mod room;
|
pub mod room;
|
||||||
|
@ -22,7 +22,7 @@ pub mod name;
|
|||||||
pub mod pinned_events;
|
pub mod pinned_events;
|
||||||
pub mod power_levels;
|
pub mod power_levels;
|
||||||
pub mod redaction;
|
pub mod redaction;
|
||||||
pub(crate) mod relationships;
|
pub mod relationships;
|
||||||
pub mod server_acl;
|
pub mod server_acl;
|
||||||
pub mod third_party_invite;
|
pub mod third_party_invite;
|
||||||
pub mod tombstone;
|
pub mod tombstone;
|
||||||
|
@ -6,15 +6,12 @@ use ruma_events_macros::MessageEventContent;
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::Value as JsonValue;
|
use serde_json::Value as JsonValue;
|
||||||
|
|
||||||
use super::{
|
|
||||||
relationships::{RelatesToJsonRepr, RelationJsonRepr},
|
|
||||||
EncryptedFile, ImageInfo, ThumbnailInfo,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub use super::relationships::{Annotation, InReplyTo};
|
|
||||||
|
|
||||||
#[cfg(feature = "unstable-pre-spec")]
|
#[cfg(feature = "unstable-pre-spec")]
|
||||||
pub use super::relationships::{Reference, Replacement};
|
use super::relationships::{Annotation, Reference, RelationJsonRepr, Replacement};
|
||||||
|
use super::{relationships::RelatesToJsonRepr, EncryptedFile, ImageInfo, ThumbnailInfo};
|
||||||
|
|
||||||
|
// FIXME: Do we want to keep re-exporting this?
|
||||||
|
pub use super::relationships::InReplyTo;
|
||||||
|
|
||||||
pub mod feedback;
|
pub mod feedback;
|
||||||
|
|
||||||
@ -78,6 +75,7 @@ pub enum Relation {
|
|||||||
Reference(Reference),
|
Reference(Reference),
|
||||||
|
|
||||||
/// An annotation to an event.
|
/// An annotation to an event.
|
||||||
|
#[cfg(feature = "unstable-pre-spec")]
|
||||||
Annotation(Annotation),
|
Annotation(Annotation),
|
||||||
|
|
||||||
/// An event that replaces another event.
|
/// An event that replaces another event.
|
||||||
@ -98,6 +96,7 @@ pub enum Relation {
|
|||||||
impl From<Relation> for RelatesToJsonRepr {
|
impl From<Relation> for RelatesToJsonRepr {
|
||||||
fn from(value: Relation) -> Self {
|
fn from(value: Relation) -> Self {
|
||||||
match value {
|
match value {
|
||||||
|
#[cfg(feature = "unstable-pre-spec")]
|
||||||
Relation::Annotation(r) => RelatesToJsonRepr::Relation(RelationJsonRepr::Annotation(r)),
|
Relation::Annotation(r) => RelatesToJsonRepr::Relation(RelationJsonRepr::Annotation(r)),
|
||||||
#[cfg(feature = "unstable-pre-spec")]
|
#[cfg(feature = "unstable-pre-spec")]
|
||||||
Relation::Reference(r) => RelatesToJsonRepr::Relation(RelationJsonRepr::Reference(r)),
|
Relation::Reference(r) => RelatesToJsonRepr::Relation(RelationJsonRepr::Reference(r)),
|
||||||
@ -114,11 +113,10 @@ impl From<Relation> for RelatesToJsonRepr {
|
|||||||
impl From<RelatesToJsonRepr> for Relation {
|
impl From<RelatesToJsonRepr> for Relation {
|
||||||
fn from(value: RelatesToJsonRepr) -> Self {
|
fn from(value: RelatesToJsonRepr) -> Self {
|
||||||
match value {
|
match value {
|
||||||
|
#[cfg(feature = "unstable-pre-spec")]
|
||||||
RelatesToJsonRepr::Relation(r) => match r {
|
RelatesToJsonRepr::Relation(r) => match r {
|
||||||
RelationJsonRepr::Annotation(a) => Self::Annotation(a),
|
RelationJsonRepr::Annotation(a) => Self::Annotation(a),
|
||||||
#[cfg(feature = "unstable-pre-spec")]
|
|
||||||
RelationJsonRepr::Reference(r) => Self::Reference(r),
|
RelationJsonRepr::Reference(r) => Self::Reference(r),
|
||||||
#[cfg(feature = "unstable-pre-spec")]
|
|
||||||
RelationJsonRepr::Replacement(r) => Self::Replacement(r),
|
RelationJsonRepr::Replacement(r) => Self::Replacement(r),
|
||||||
},
|
},
|
||||||
RelatesToJsonRepr::Reply { in_reply_to } => Self::Reply { in_reply_to },
|
RelatesToJsonRepr::Reply { in_reply_to } => Self::Reply { in_reply_to },
|
||||||
|
@ -17,6 +17,7 @@ use serde_json::Value as JsonValue;
|
|||||||
pub(crate) enum RelatesToJsonRepr {
|
pub(crate) enum RelatesToJsonRepr {
|
||||||
/// A relation which contains subtypes indicating the type of the
|
/// A relation which contains subtypes indicating the type of the
|
||||||
/// relationship with the `rel_type` field.
|
/// relationship with the `rel_type` field.
|
||||||
|
#[cfg(feature = "unstable-pre-spec")]
|
||||||
Relation(RelationJsonRepr),
|
Relation(RelationJsonRepr),
|
||||||
|
|
||||||
/// An `m.in_reply_to` relationship indicating that the event is a reply to
|
/// An `m.in_reply_to` relationship indicating that the event is a reply to
|
||||||
@ -33,6 +34,7 @@ pub(crate) enum RelatesToJsonRepr {
|
|||||||
|
|
||||||
/// A relation, which associates new information to an existing event.
|
/// A relation, which associates new information to an existing event.
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
|
#[cfg(feature = "unstable-pre-spec")]
|
||||||
#[serde(tag = "rel_type")]
|
#[serde(tag = "rel_type")]
|
||||||
pub(crate) enum RelationJsonRepr {
|
pub(crate) enum RelationJsonRepr {
|
||||||
/// An annotation to an event.
|
/// An annotation to an event.
|
||||||
@ -40,12 +42,10 @@ pub(crate) enum RelationJsonRepr {
|
|||||||
Annotation(Annotation),
|
Annotation(Annotation),
|
||||||
|
|
||||||
/// A reference to another event.
|
/// A reference to another event.
|
||||||
#[cfg(feature = "unstable-pre-spec")]
|
|
||||||
#[serde(rename = "m.reference")]
|
#[serde(rename = "m.reference")]
|
||||||
Reference(Reference),
|
Reference(Reference),
|
||||||
|
|
||||||
/// An event that replaces another event.
|
/// An event that replaces another event.
|
||||||
#[cfg(feature = "unstable-pre-spec")]
|
|
||||||
#[serde(rename = "m.replace")]
|
#[serde(rename = "m.replace")]
|
||||||
Replacement(Replacement),
|
Replacement(Replacement),
|
||||||
}
|
}
|
||||||
@ -142,6 +142,7 @@ mod test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg(feature = "unstable-pre-spec")]
|
||||||
fn annotation_deserialize() {
|
fn annotation_deserialize() {
|
||||||
let event_id = event_id!("$1598361704261elfgc:localhost");
|
let event_id = event_id!("$1598361704261elfgc:localhost");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user