events: Add the to-device variant of the m.key.verification.done event

This commit is contained in:
Damir Jelić 2021-05-12 15:04:03 +02:00 committed by Jonas Platte
parent 166ee8b9d7
commit d971b668ec
3 changed files with 20 additions and 2 deletions

View File

@ -115,6 +115,9 @@ event_enum! {
"m.key.verification.accept", "m.key.verification.accept",
"m.key.verification.key", "m.key.verification.key",
"m.key.verification.mac", "m.key.verification.mac",
#[cfg(feature = "unstable-pre-spec")]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable-pre-spec")))]
"m.key.verification.done",
"m.room.encrypted", "m.room.encrypted",
] ]
} }

View File

@ -48,6 +48,10 @@ pub enum EventType {
#[ruma_enum(rename = "m.key.verification.cancel")] #[ruma_enum(rename = "m.key.verification.cancel")]
KeyVerificationCancel, KeyVerificationCancel,
/// m.key.verification.done
#[ruma_enum(rename = "m.key.verification.done")]
KeyVerificationDone,
/// m.key.verification.key /// m.key.verification.key
#[ruma_enum(rename = "m.key.verification.key")] #[ruma_enum(rename = "m.key.verification.key")]
KeyVerificationKey, KeyVerificationKey,
@ -231,6 +235,7 @@ mod tests {
serde_json_eq(EventType::FullyRead, json!("m.fully_read")); serde_json_eq(EventType::FullyRead, json!("m.fully_read"));
serde_json_eq(EventType::KeyVerificationAccept, json!("m.key.verification.accept")); serde_json_eq(EventType::KeyVerificationAccept, json!("m.key.verification.accept"));
serde_json_eq(EventType::KeyVerificationCancel, json!("m.key.verification.cancel")); serde_json_eq(EventType::KeyVerificationCancel, json!("m.key.verification.cancel"));
serde_json_eq(EventType::KeyVerificationDone, json!("m.key.verification.done"));
serde_json_eq(EventType::KeyVerificationKey, json!("m.key.verification.key")); serde_json_eq(EventType::KeyVerificationKey, json!("m.key.verification.key"));
serde_json_eq(EventType::KeyVerificationMac, json!("m.key.verification.mac")); serde_json_eq(EventType::KeyVerificationMac, json!("m.key.verification.mac"));
serde_json_eq(EventType::KeyVerificationReady, json!("m.key.verification.ready")); serde_json_eq(EventType::KeyVerificationReady, json!("m.key.verification.ready"));

View File

@ -1,6 +1,6 @@
//! Types for the *m.key.verification.done* event. //! Types for the *m.key.verification.done* event.
use ruma_events_macros::MessageEventContent; use ruma_events_macros::{EventContent, MessageEventContent};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use super::Relation; use super::Relation;
@ -10,7 +10,17 @@ use crate::MessageEvent;
/// concluded. /// concluded.
pub type DoneEvent = MessageEvent<DoneEventContent>; pub type DoneEvent = MessageEvent<DoneEventContent>;
/// The payload for `DoneEvent`. /// The payload for a to-device `m.key.verification.done` event.
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[ruma_event(type = "m.key.verification.done")]
pub struct DoneToDeviceEventContent {
/// An opaque identifier for the verification process.
///
/// Must be the same as the one used for the *m.key.verification.start* message.
pub transaction_id: String,
}
/// The payload for a in-room `m.key.verification.done` event.
#[derive(Clone, Debug, Deserialize, Serialize, MessageEventContent)] #[derive(Clone, Debug, Deserialize, Serialize, MessageEventContent)]
#[ruma_event(type = "m.key.verification.done")] #[ruma_event(type = "m.key.verification.done")]
pub struct DoneEventContent { pub struct DoneEventContent {