diff --git a/crates/ruma-events/src/enums.rs b/crates/ruma-events/src/enums.rs index 67d8fd5c..bdfd8532 100644 --- a/crates/ruma-events/src/enums.rs +++ b/crates/ruma-events/src/enums.rs @@ -5,7 +5,7 @@ use serde::{de, Deserialize, Serialize}; use serde_json::value::RawValue as RawJsonValue; use crate::{ - from_raw_json_value, + from_raw_json_value, key, room::{encrypted, message, redaction::SyncRoomRedactionEvent}, Redact, UnsignedDeHelper, }; @@ -36,19 +36,12 @@ event_enum! { "m.call.invite", "m.call.hangup", "m.call.candidates", - #[cfg(feature = "unstable-pre-spec")] "m.key.verification.ready", - #[cfg(feature = "unstable-pre-spec")] "m.key.verification.start", - #[cfg(feature = "unstable-pre-spec")] "m.key.verification.cancel", - #[cfg(feature = "unstable-pre-spec")] "m.key.verification.accept", - #[cfg(feature = "unstable-pre-spec")] "m.key.verification.key", - #[cfg(feature = "unstable-pre-spec")] "m.key.verification.mac", - #[cfg(feature = "unstable-pre-spec")] "m.key.verification.done", #[cfg(feature = "unstable-pre-spec")] "m.reaction", @@ -93,14 +86,12 @@ event_enum! { "m.room_key_request", "m.forwarded_room_key", "m.key.verification.request", - #[cfg(feature = "unstable-pre-spec")] "m.key.verification.ready", "m.key.verification.start", "m.key.verification.cancel", "m.key.verification.accept", "m.key.verification.key", "m.key.verification.mac", - #[cfg(feature = "unstable-pre-spec")] "m.key.verification.done", "m.room.encrypted", #[cfg(feature = "unstable-pre-spec")] @@ -331,23 +322,14 @@ impl AnyMessageEventContent { /// This is a helper function intended for encryption. There should not be a reason to access /// `m.relates_to` without first destructuring an `AnyMessageEventContent` otherwise. pub fn relation(&self) -> Option { - #[cfg(feature = "unstable-pre-spec")] - use crate::{ - key::{ - self, - verification::{ - accept::KeyVerificationAcceptEventContent, - cancel::KeyVerificationCancelEventContent, - done::KeyVerificationDoneEventContent, key::KeyVerificationKeyEventContent, - mac::KeyVerificationMacEventContent, ready::KeyVerificationReadyEventContent, - start::KeyVerificationStartEventContent, - }, - }, - reaction, + use crate::key::verification::{ + accept::KeyVerificationAcceptEventContent, cancel::KeyVerificationCancelEventContent, + done::KeyVerificationDoneEventContent, key::KeyVerificationKeyEventContent, + mac::KeyVerificationMacEventContent, ready::KeyVerificationReadyEventContent, + start::KeyVerificationStartEventContent, }; match self { - #[cfg(feature = "unstable-pre-spec")] #[rustfmt::skip] Self::KeyVerificationReady(KeyVerificationReadyEventContent { relates_to, .. }) | Self::KeyVerificationStart(KeyVerificationStartEventContent { relates_to, .. }) @@ -363,6 +345,8 @@ impl AnyMessageEventContent { } #[cfg(feature = "unstable-pre-spec")] Self::Reaction(ev) => { + use crate::reaction; + let reaction::Relation { event_id, emoji } = &ev.relates_to; Some(encrypted::Relation::Annotation(encrypted::Annotation { event_id: event_id.clone(), diff --git a/crates/ruma-events/src/key/verification.rs b/crates/ruma-events/src/key/verification.rs index f1bc6ff6..63c10c0c 100644 --- a/crates/ruma-events/src/key/verification.rs +++ b/crates/ruma-events/src/key/verification.rs @@ -6,21 +6,18 @@ //! [on GitHub][github-matrix-doc-2214]. //! //! [github-matrix-doc-2214]: https://github.com/matrix-org/matrix-doc/pull/2241 -#[cfg(feature = "unstable-pre-spec")] + use ruma_identifiers::EventId; use ruma_serde::StringEnum; -#[cfg(feature = "unstable-pre-spec")] use serde::{Deserialize, Serialize}; use crate::PrivOwnedStr; pub mod accept; pub mod cancel; -#[cfg(feature = "unstable-pre-spec")] pub mod done; pub mod key; pub mod mac; -#[cfg(feature = "unstable-pre-spec")] pub mod ready; pub mod request; pub mod start; @@ -124,7 +121,6 @@ impl ShortAuthenticationString { /// A relation which associates an `m.key.verification.request` with another key verification event. #[derive(Clone, Debug, Deserialize, Serialize)] -#[cfg(feature = "unstable-pre-spec")] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[serde(tag = "rel_type", rename = "m.reference")] pub struct Relation { @@ -132,7 +128,6 @@ pub struct Relation { pub event_id: Box, } -#[cfg(feature = "unstable-pre-spec")] impl Relation { /// Creates a new `Relation` with the given event ID. pub fn new(event_id: Box) -> Self { @@ -152,17 +147,14 @@ pub enum VerificationMethod { SasV1, /// The `m.qr_code.scan.v1` verification method. - #[cfg(feature = "unstable-pre-spec")] #[ruma_enum(rename = "m.qr_code.scan.v1")] QrCodeScanV1, /// The `m.qr_code.show.v1` verification method. - #[cfg(feature = "unstable-pre-spec")] #[ruma_enum(rename = "m.qr_code.show.v1")] QrCodeShowV1, /// The `m.reciprocate.v1` verification method. - #[cfg(feature = "unstable-pre-spec")] #[ruma_enum(rename = "m.reciprocate.v1")] ReciprocateV1, diff --git a/crates/ruma-events/src/key/verification/accept.rs b/crates/ruma-events/src/key/verification/accept.rs index 48cd4761..6da9ddcd 100644 --- a/crates/ruma-events/src/key/verification/accept.rs +++ b/crates/ruma-events/src/key/verification/accept.rs @@ -10,10 +10,9 @@ use ruma_serde::Base64; use serde::{Deserialize, Serialize}; use serde_json::Value as JsonValue; -#[cfg(feature = "unstable-pre-spec")] -use super::Relation; use super::{ - HashAlgorithm, KeyAgreementProtocol, MessageAuthenticationCode, ShortAuthenticationString, + HashAlgorithm, KeyAgreementProtocol, MessageAuthenticationCode, Relation, + ShortAuthenticationString, }; /// The content of a to-device `m.key.verification.accept` event. @@ -46,7 +45,6 @@ impl ToDeviceKeyVerificationAcceptEventContent { /// Accepts a previously sent `m.key.verification.start` message. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[ruma_event(type = "m.key.verification.accept", kind = Message)] -#[cfg(feature = "unstable-pre-spec")] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] pub struct KeyVerificationAcceptEventContent { /// The method specific content. @@ -58,7 +56,6 @@ pub struct KeyVerificationAcceptEventContent { pub relates_to: Relation, } -#[cfg(feature = "unstable-pre-spec")] impl KeyVerificationAcceptEventContent { /// Creates a new `ToDeviceKeyVerificationAcceptEventContent` with the given method-specific /// content and relation. @@ -169,23 +166,18 @@ mod tests { use std::collections::BTreeMap; use matches::assert_matches; - #[cfg(feature = "unstable-pre-spec")] - use ruma_identifiers::event_id; - use ruma_identifiers::user_id; + use ruma_identifiers::{event_id, user_id}; use ruma_serde::Base64; use serde_json::{ from_value as from_json_value, json, to_value as to_json_value, Value as JsonValue, }; - #[cfg(feature = "unstable-pre-spec")] - use super::KeyVerificationAcceptEventContent; use super::{ - AcceptMethod, HashAlgorithm, KeyAgreementProtocol, MessageAuthenticationCode, SasV1Content, - ShortAuthenticationString, ToDeviceKeyVerificationAcceptEventContent, _CustomContent, + AcceptMethod, HashAlgorithm, KeyAgreementProtocol, KeyVerificationAcceptEventContent, + MessageAuthenticationCode, SasV1Content, ShortAuthenticationString, + ToDeviceKeyVerificationAcceptEventContent, _CustomContent, }; - #[cfg(feature = "unstable-pre-spec")] - use crate::key::verification::Relation; - use crate::ToDeviceEvent; + use crate::{key::verification::Relation, ToDeviceEvent}; #[test] fn serialization() { @@ -250,7 +242,6 @@ mod tests { } #[test] - #[cfg(feature = "unstable-pre-spec")] fn in_room_serialization() { let event_id = event_id!("$1598361704261elfgc:localhost"); @@ -384,7 +375,6 @@ mod tests { } #[test] - #[cfg(feature = "unstable-pre-spec")] fn in_room_deserialization() { let id = event_id!("$1598361704261elfgc:localhost"); diff --git a/crates/ruma-events/src/key/verification/cancel.rs b/crates/ruma-events/src/key/verification/cancel.rs index a828898e..edb0be48 100644 --- a/crates/ruma-events/src/key/verification/cancel.rs +++ b/crates/ruma-events/src/key/verification/cancel.rs @@ -7,10 +7,8 @@ use ruma_identifiers::TransactionId; use ruma_serde::StringEnum; use serde::{Deserialize, Serialize}; -use crate::PrivOwnedStr; - -#[cfg(feature = "unstable-pre-spec")] use super::Relation; +use crate::PrivOwnedStr; /// The content of a to-device `m.key.verification.cancel` event. /// @@ -43,7 +41,6 @@ impl ToDeviceKeyVerificationCancelEventContent { /// /// Cancels a key verification process/request. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] -#[cfg(feature = "unstable-pre-spec")] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.key.verification.cancel", kind = Message)] pub struct KeyVerificationCancelEventContent { @@ -60,7 +57,6 @@ pub struct KeyVerificationCancelEventContent { pub relates_to: Relation, } -#[cfg(feature = "unstable-pre-spec")] impl KeyVerificationCancelEventContent { /// Creates a new `KeyVerificationCancelEventContent` with the given reason, code and relation. pub fn new(reason: String, code: CancelCode, relates_to: Relation) -> Self { diff --git a/crates/ruma-events/src/key/verification/key.rs b/crates/ruma-events/src/key/verification/key.rs index 3e5cd4b7..cdef3757 100644 --- a/crates/ruma-events/src/key/verification/key.rs +++ b/crates/ruma-events/src/key/verification/key.rs @@ -7,7 +7,6 @@ use ruma_identifiers::TransactionId; use ruma_serde::Base64; use serde::{Deserialize, Serialize}; -#[cfg(feature = "unstable-pre-spec")] use super::Relation; /// The content of a to-device `m.key.verification.key` event. @@ -38,7 +37,6 @@ impl ToDeviceKeyVerificationKeyEventContent { /// /// Sends the ephemeral public key for a device to the partner device. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] -#[cfg(feature = "unstable-pre-spec")] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.key.verification.key", kind = Message)] pub struct KeyVerificationKeyEventContent { @@ -50,7 +48,6 @@ pub struct KeyVerificationKeyEventContent { pub relates_to: Relation, } -#[cfg(feature = "unstable-pre-spec")] impl KeyVerificationKeyEventContent { /// Creates a new `KeyVerificationKeyEventContent` with the given key and relation. pub fn new(key: Base64, relates_to: Relation) -> Self { diff --git a/crates/ruma-events/src/key/verification/mac.rs b/crates/ruma-events/src/key/verification/mac.rs index 64d449cc..702ab903 100644 --- a/crates/ruma-events/src/key/verification/mac.rs +++ b/crates/ruma-events/src/key/verification/mac.rs @@ -9,7 +9,6 @@ use ruma_identifiers::TransactionId; use ruma_serde::Base64; use serde::{Deserialize, Serialize}; -#[cfg(feature = "unstable-pre-spec")] use super::Relation; /// The content of a to-device `m.key.verification.` event. @@ -50,7 +49,6 @@ impl ToDeviceKeyVerificationMacEventContent { /// /// Sends the MAC of a device's key to the partner device. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] -#[cfg(feature = "unstable-pre-spec")] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.key.verification.mac", kind = Message)] pub struct KeyVerificationMacEventContent { @@ -68,7 +66,6 @@ pub struct KeyVerificationMacEventContent { pub relates_to: Relation, } -#[cfg(feature = "unstable-pre-spec")] impl KeyVerificationMacEventContent { /// Creates a new `KeyVerificationMacEventContent` with the given key ID to MAC map, key MAC and /// relation. diff --git a/crates/ruma-events/src/key/verification/start.rs b/crates/ruma-events/src/key/verification/start.rs index b54d4712..7f0021d9 100644 --- a/crates/ruma-events/src/key/verification/start.rs +++ b/crates/ruma-events/src/key/verification/start.rs @@ -6,15 +6,13 @@ use std::collections::BTreeMap; use ruma_events_macros::EventContent; use ruma_identifiers::{DeviceId, TransactionId}; -#[cfg(feature = "unstable-pre-spec")] use ruma_serde::Base64; use serde::{Deserialize, Serialize}; use serde_json::Value as JsonValue; -#[cfg(feature = "unstable-pre-spec")] -use super::Relation; use super::{ - HashAlgorithm, KeyAgreementProtocol, MessageAuthenticationCode, ShortAuthenticationString, + HashAlgorithm, KeyAgreementProtocol, MessageAuthenticationCode, Relation, + ShortAuthenticationString, }; /// The content of a to-device `m.key.verification.start` event. @@ -55,7 +53,6 @@ impl ToDeviceKeyVerificationStartEventContent { /// /// Begins an SAS key verification process. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] -#[cfg(feature = "unstable-pre-spec")] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.key.verification.start", kind = Message)] pub struct KeyVerificationStartEventContent { @@ -71,7 +68,6 @@ pub struct KeyVerificationStartEventContent { pub relates_to: Relation, } -#[cfg(feature = "unstable-pre-spec")] impl KeyVerificationStartEventContent { /// Creates a new `KeyVerificationStartEventContent` with the given device ID, method and /// relation. @@ -93,7 +89,6 @@ pub enum StartMethod { /// The spec entry for this method can be found [here][1]. /// /// [1]: https://spec.matrix.org/unstable/client-server-api/#mkeyverificationstartmreciprocatev1 - #[cfg(feature = "unstable-pre-spec")] ReciprocateV1(ReciprocateV1Content), /// Any unknown start method. @@ -116,7 +111,6 @@ pub struct _CustomContent { /// The payload of an `m.key.verification.start` event using the `m.sas.v1` method. #[derive(Clone, Debug, Deserialize, Serialize)] -#[cfg(feature = "unstable-pre-spec")] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[serde(rename = "m.reciprocate.v1", tag = "method")] pub struct ReciprocateV1Content { @@ -124,7 +118,6 @@ pub struct ReciprocateV1Content { pub secret: Base64, } -#[cfg(feature = "unstable-pre-spec")] impl ReciprocateV1Content { /// Create a new `ReciprocateV1Content` with the given shared secret. /// @@ -208,25 +201,19 @@ mod tests { use std::collections::BTreeMap; use matches::assert_matches; - #[cfg(feature = "unstable-pre-spec")] - use ruma_identifiers::event_id; - use ruma_identifiers::user_id; - #[cfg(feature = "unstable-pre-spec")] + use ruma_identifiers::{event_id, user_id}; use ruma_serde::Base64; use serde_json::{ from_value as from_json_value, json, to_value as to_json_value, Value as JsonValue, }; use super::{ - HashAlgorithm, KeyAgreementProtocol, MessageAuthenticationCode, SasV1Content, - SasV1ContentInit, ShortAuthenticationString, StartMethod, - ToDeviceKeyVerificationStartEventContent, _CustomContent, + HashAlgorithm, KeyAgreementProtocol, KeyVerificationStartEventContent, + MessageAuthenticationCode, ReciprocateV1Content, SasV1Content, SasV1ContentInit, + ShortAuthenticationString, StartMethod, ToDeviceKeyVerificationStartEventContent, + _CustomContent, }; - #[cfg(feature = "unstable-pre-spec")] - use super::{KeyVerificationStartEventContent, ReciprocateV1Content}; - #[cfg(feature = "unstable-pre-spec")] - use crate::key::verification::Relation; - use crate::ToDeviceEvent; + use crate::{key::verification::Relation, ToDeviceEvent}; #[test] fn serialization() { @@ -294,7 +281,6 @@ mod tests { assert_eq!(to_json_value(&key_verification_start).unwrap(), json_data); - #[cfg(feature = "unstable-pre-spec")] { let secret = Base64::new(b"This is a secret to everybody".to_vec()); @@ -316,7 +302,6 @@ mod tests { } #[test] - #[cfg(feature = "unstable-pre-spec")] fn in_room_serialization() { let event_id = event_id!("$1598361704261elfgc:localhost"); @@ -470,7 +455,6 @@ mod tests { && data.get("test").unwrap() == &JsonValue::from("field") ); - #[cfg(feature = "unstable-pre-spec")] { let json = json!({ "content": { @@ -501,7 +485,6 @@ mod tests { } #[test] - #[cfg(feature = "unstable-pre-spec")] fn in_room_deserialization() { let id = event_id!("$1598361704261elfgc:localhost"); diff --git a/crates/ruma-events/src/room/encrypted.rs b/crates/ruma-events/src/room/encrypted.rs index c719f087..c9c2f2fa 100644 --- a/crates/ruma-events/src/room/encrypted.rs +++ b/crates/ruma-events/src/room/encrypted.rs @@ -6,9 +6,7 @@ use std::collections::BTreeMap; use js_int::UInt; use ruma_events_macros::EventContent; -use ruma_identifiers::DeviceId; -#[cfg(feature = "unstable-pre-spec")] -use ruma_identifiers::EventId; +use ruma_identifiers::{DeviceId, EventId}; use serde::{Deserialize, Serialize}; use crate::room::message::InReplyTo; @@ -99,7 +97,6 @@ pub enum Relation { Replacement(Replacement), /// A reference to another event. - #[cfg(feature = "unstable-pre-spec")] Reference(Reference), /// An annotation to an event. @@ -124,14 +121,12 @@ pub struct Replacement { /// A reference to another event. #[derive(Clone, Debug, Deserialize, Serialize)] -#[cfg(feature = "unstable-pre-spec")] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] pub struct Reference { /// The event we are referencing. pub event_id: Box, } -#[cfg(feature = "unstable-pre-spec")] impl Reference { /// Creates a new `Reference` with the given event ID. pub fn new(event_id: Box) -> Self { diff --git a/crates/ruma-events/src/room/encrypted/relation_serde.rs b/crates/ruma-events/src/room/encrypted/relation_serde.rs index 1815ec81..0e551a29 100644 --- a/crates/ruma-events/src/room/encrypted/relation_serde.rs +++ b/crates/ruma-events/src/room/encrypted/relation_serde.rs @@ -1,8 +1,8 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer}; #[cfg(feature = "unstable-pre-spec")] -use super::{Annotation, Reference, Replacement}; -use super::{InReplyTo, Relation}; +use super::{Annotation, Replacement}; +use super::{InReplyTo, Reference, Relation}; impl<'de> Deserialize<'de> for Relation { fn deserialize(deserializer: D) -> Result @@ -14,11 +14,12 @@ impl<'de> Deserialize<'de> for Relation { return Relation::Reply { in_reply_to }; } - #[cfg(feature = "unstable-pre-spec")] if let Some(relation) = ev.relates_to.relation { return match relation { + #[cfg(feature = "unstable-pre-spec")] RelationJsonRepr::Annotation(a) => Relation::Annotation(a), RelationJsonRepr::Reference(r) => Relation::Reference(r), + #[cfg(feature = "unstable-pre-spec")] RelationJsonRepr::Replacement(Replacement { event_id }) => { Relation::Replacement(Replacement { event_id }) } @@ -47,7 +48,6 @@ impl Serialize for Relation { relation: Some(RelationJsonRepr::Annotation(r.clone())), ..Default::default() }, - #[cfg(feature = "unstable-pre-spec")] Relation::Reference(r) => RelatesToJsonRepr { relation: Some(RelationJsonRepr::Reference(r.clone())), ..Default::default() @@ -80,31 +80,22 @@ struct RelatesToJsonRepr { #[serde(rename = "m.in_reply_to", skip_serializing_if = "Option::is_none")] in_reply_to: Option, - #[cfg(feature = "unstable-pre-spec")] #[serde(flatten, skip_serializing_if = "Option::is_none")] relation: Option, } impl RelatesToJsonRepr { fn is_empty(&self) -> bool { - #[cfg(not(feature = "unstable-pre-spec"))] - { - self.in_reply_to.is_none() - } - - #[cfg(feature = "unstable-pre-spec")] - { - self.in_reply_to.is_none() && self.relation.is_none() - } + self.in_reply_to.is_none() && self.relation.is_none() } } /// A relation, which associates new information to an existing event. #[derive(Clone, Deserialize, Serialize)] -#[cfg(feature = "unstable-pre-spec")] #[serde(tag = "rel_type")] enum RelationJsonRepr { /// An annotation to an event. + #[cfg(feature = "unstable-pre-spec")] #[serde(rename = "m.annotation")] Annotation(Annotation), @@ -113,6 +104,7 @@ enum RelationJsonRepr { Reference(Reference), /// An event that replaces another event. + #[cfg(feature = "unstable-pre-spec")] #[serde(rename = "m.replace")] Replacement(Replacement), diff --git a/crates/ruma-events/src/room/message.rs b/crates/ruma-events/src/room/message.rs index 3c64d2bf..e8e08fbd 100644 --- a/crates/ruma-events/src/room/message.rs +++ b/crates/ruma-events/src/room/message.rs @@ -6,17 +6,13 @@ use std::{borrow::Cow, fmt}; use js_int::UInt; use ruma_events_macros::EventContent; -#[cfg(feature = "unstable-pre-spec")] -use ruma_identifiers::{DeviceId, UserId}; -use ruma_identifiers::{EventId, MxcUri}; +use ruma_identifiers::{DeviceId, EventId, MxcUri, UserId}; use ruma_serde::{JsonObject, StringEnum}; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use serde_json::Value as JsonValue; use super::{EncryptedFile, ImageInfo, ThumbnailInfo}; -#[cfg(feature = "unstable-pre-spec")] -use crate::key::verification::VerificationMethod; -use crate::PrivOwnedStr; +use crate::{key::verification::VerificationMethod, PrivOwnedStr}; mod content_serde; pub mod feedback; @@ -215,7 +211,6 @@ pub enum MessageType { Video(VideoMessageEventContent), /// A request to initiate a key verification. - #[cfg(feature = "unstable-pre-spec")] VerificationRequest(KeyVerificationRequestEventContent), /// A custom message. @@ -253,7 +248,6 @@ impl MessageType { "m.server_notice" => Self::ServerNotice(deserialize_variant(body, data)?), "m.text" => Self::Text(deserialize_variant(body, data)?), "m.video" => Self::Video(deserialize_variant(body, data)?), - #[cfg(feature = "unstable-pre-spec")] "m.key.verification.request" => { Self::VerificationRequest(deserialize_variant(body, data)?) } @@ -273,7 +267,6 @@ impl MessageType { Self::ServerNotice(_) => "m.server_notice", Self::Text(_) => "m.text", Self::Video(_) => "m.video", - #[cfg(feature = "unstable-pre-spec")] Self::VerificationRequest(_) => "m.key.verification.request", Self::_Custom(c) => &c.msgtype, } @@ -291,7 +284,6 @@ impl MessageType { MessageType::ServerNotice(m) => &m.body, MessageType::Text(m) => &m.body, MessageType::Video(m) => &m.body, - #[cfg(feature = "unstable-pre-spec")] MessageType::VerificationRequest(m) => &m.body, MessageType::_Custom(m) => &m.body, } @@ -325,7 +317,6 @@ impl MessageType { Self::ServerNotice(d) => Cow::Owned(serialize(d)), Self::Text(d) => Cow::Owned(serialize(d)), Self::Video(d) => Cow::Owned(serialize(d)), - #[cfg(feature = "unstable-pre-spec")] Self::VerificationRequest(d) => Cow::Owned(serialize(d)), Self::_Custom(c) => Cow::Borrowed(&c.data), } @@ -959,7 +950,6 @@ impl VideoInfo { /// The payload for a key verification request message. #[derive(Clone, Debug, Deserialize, Serialize)] -#[cfg(feature = "unstable-pre-spec")] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[serde(tag = "msgtype", rename = "m.key.verification.request")] pub struct KeyVerificationRequestEventContent { @@ -981,7 +971,6 @@ pub struct KeyVerificationRequestEventContent { pub to: Box, } -#[cfg(feature = "unstable-pre-spec")] impl KeyVerificationRequestEventContent { /// Creates a new `RoomKeyVerificationRequestEventContent` with the given body, method, device /// and user ID. diff --git a/crates/ruma-events/src/room/message/reply.rs b/crates/ruma-events/src/room/message/reply.rs index 33970d08..0b8e9142 100644 --- a/crates/ruma-events/src/room/message/reply.rs +++ b/crates/ruma-events/src/room/message/reply.rs @@ -82,7 +82,6 @@ pub fn get_plain_quote_fallback(original_message: &impl ReplyBaseEvent) -> Strin MessageType::_Custom(content) => { format!("> <{}> {}", sender, content.body) } - #[cfg(feature = "unstable-pre-spec")] MessageType::VerificationRequest(content) => { format!("> <{}> {}", sender, content.body) } @@ -268,7 +267,6 @@ pub fn get_html_quote_fallback(original_message: &RoomMessageEvent) -> String { body = content.body, ) } - #[cfg(feature = "unstable-pre-spec")] MessageType::VerificationRequest(content) => { formatdoc!( " diff --git a/crates/ruma-events/tests/enums.rs b/crates/ruma-events/tests/enums.rs index 70b3fbf8..ba26c785 100644 --- a/crates/ruma-events/tests/enums.rs +++ b/crates/ruma-events/tests/enums.rs @@ -335,13 +335,11 @@ fn serialize_and_deserialize_from_display_form() { serde_json_eq(RoomAccountDataEventType::FullyRead, json!("m.fully_read")); serde_json_eq(EventType::KeyVerificationAccept, json!("m.key.verification.accept")); serde_json_eq(EventType::KeyVerificationCancel, json!("m.key.verification.cancel")); - // m.key.verification.ready is unstable-pre-spec - // serde_json_eq(EventType::KeyVerificationDone, json!("m.key.verification.done")); + serde_json_eq(EventType::KeyVerificationDone, json!("m.key.verification.done")); serde_json_eq(EventType::KeyVerificationKey, json!("m.key.verification.key")); serde_json_eq(ToDeviceEventType::KeyVerificationKey, json!("m.key.verification.key")); serde_json_eq(EventType::KeyVerificationMac, json!("m.key.verification.mac")); - // m.key.verification.ready is unstable-pre-spec - // serde_json_eq(EventType::KeyVerificationReady, json!("m.key.verification.ready")); + serde_json_eq(EventType::KeyVerificationReady, json!("m.key.verification.ready")); serde_json_eq(EventType::KeyVerificationRequest, json!("m.key.verification.request")); serde_json_eq(EventType::KeyVerificationStart, json!("m.key.verification.start")); serde_json_eq(EventType::IgnoredUserList, json!("m.ignored_user_list")); diff --git a/crates/ruma-events/tests/room_message.rs b/crates/ruma-events/tests/room_message.rs index 91555144..c2ca006f 100644 --- a/crates/ruma-events/tests/room_message.rs +++ b/crates/ruma-events/tests/room_message.rs @@ -4,20 +4,15 @@ use assign::assign; use js_int::uint; use matches::assert_matches; use ruma_common::MilliSecondsSinceUnixEpoch; -#[cfg(feature = "unstable-pre-spec")] -use ruma_events::{ - key::verification::VerificationMethod, room::message::KeyVerificationRequestEventContent, -}; use ruma_events::{ + key::verification::VerificationMethod, room::message::{ - AudioMessageEventContent, InReplyTo, MessageType, Relation, RoomMessageEvent, - RoomMessageEventContent, TextMessageEventContent, + AudioMessageEventContent, InReplyTo, KeyVerificationRequestEventContent, MessageType, + Relation, RoomMessageEvent, RoomMessageEventContent, TextMessageEventContent, }, Unsigned, }; -#[cfg(feature = "unstable-pre-spec")] -use ruma_identifiers::DeviceId; -use ruma_identifiers::{event_id, mxc_uri, room_id, user_id}; +use ruma_identifiers::{event_id, mxc_uri, room_id, user_id, DeviceId}; use serde_json::{from_value as from_json_value, json, to_value as to_json_value}; macro_rules! json_object { @@ -297,7 +292,6 @@ fn edit_deserialization_future() { } #[test] -#[cfg(feature = "unstable-pre-spec")] fn verification_request_deserialization() { let user_id = user_id!("@example2:localhost"); let device_id: Box = "XOWLHHFSWM".into(); @@ -333,7 +327,6 @@ fn verification_request_deserialization() { } #[test] -#[cfg(feature = "unstable-pre-spec")] fn verification_request_serialization() { let user_id = user_id!("@example2:localhost").to_owned(); let device_id: Box = "XOWLHHFSWM".into();