Convert m.key.verification.{accept,cancel,key,mac,request} and
m.room_key to the new API.
This commit is contained in:
parent
3c70dac634
commit
20d2482108
@ -37,9 +37,7 @@ mod tests {
|
|||||||
|
|
||||||
content.insert(alice.clone(), room.clone());
|
content.insert(alice.clone(), room.clone());
|
||||||
|
|
||||||
let event = DirectEvent {
|
let event = DirectEvent { content };
|
||||||
content,
|
|
||||||
};
|
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
to_string(&event).unwrap(),
|
to_string(&event).unwrap(),
|
||||||
|
@ -29,10 +29,8 @@ mod tests {
|
|||||||
use super::{DummyEvent, Empty};
|
use super::{DummyEvent, Empty};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn serialization() {
|
fn serialization() {
|
||||||
let dummy_event = DummyEvent {
|
let dummy_event = DummyEvent { content: Empty };
|
||||||
content: Empty,
|
|
||||||
};
|
|
||||||
|
|
||||||
let actual = serde_json::to_string(&dummy_event).unwrap();
|
let actual = serde_json::to_string(&dummy_event).unwrap();
|
||||||
let expected = r#"{"content":{},"type":"m.dummy"}"#;
|
let expected = r#"{"content":{},"type":"m.dummy"}"#;
|
||||||
|
@ -5,7 +5,7 @@ use std::collections::HashMap;
|
|||||||
use ruma_identifiers::UserId;
|
use ruma_identifiers::UserId;
|
||||||
use serde::{ser::SerializeStruct, Deserialize, Deserializer, Serialize, Serializer};
|
use serde::{ser::SerializeStruct, Deserialize, Deserializer, Serialize, Serializer};
|
||||||
|
|
||||||
use crate::{Empty, Event};
|
use crate::{Empty, Event, EventType};
|
||||||
|
|
||||||
/// A list of users to ignore.
|
/// A list of users to ignore.
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
@ -37,7 +37,7 @@ impl IgnoredUserListEvent {
|
|||||||
impl Serialize for IgnoredUserListEvent {
|
impl Serialize for IgnoredUserListEvent {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
S: Serializer
|
S: Serializer,
|
||||||
{
|
{
|
||||||
let mut state = serializer.serialize_struct("IgnoredUserListEvent", 2)?;
|
let mut state = serializer.serialize_struct("IgnoredUserListEvent", 2)?;
|
||||||
|
|
||||||
@ -49,9 +49,6 @@ impl Serialize for IgnoredUserListEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl crate::Event for IgnoredUserListEvent {
|
impl crate::Event for IgnoredUserListEvent {
|
||||||
/// The type of the event.
|
|
||||||
const EVENT_TYPE: crate::EventType = crate::EventType::IgnoredUserList;
|
|
||||||
|
|
||||||
/// The type of this event's `content` field.
|
/// The type of this event's `content` field.
|
||||||
type Content = IgnoredUserListEventContent;
|
type Content = IgnoredUserListEventContent;
|
||||||
|
|
||||||
@ -59,12 +56,17 @@ impl crate::Event for IgnoredUserListEvent {
|
|||||||
fn content(&self) -> &Self::Content {
|
fn content(&self) -> &Self::Content {
|
||||||
&self.content
|
&self.content
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The type of the event.
|
||||||
|
fn event_type(&self) -> EventType {
|
||||||
|
EventType::IgnoredUserList
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Serialize for IgnoredUserListEventContent {
|
impl Serialize for IgnoredUserListEventContent {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
S: Serializer
|
S: Serializer,
|
||||||
{
|
{
|
||||||
let mut map = HashMap::new();
|
let mut map = HashMap::new();
|
||||||
|
|
||||||
@ -72,17 +74,15 @@ impl Serialize for IgnoredUserListEventContent {
|
|||||||
map.insert(user_id.clone(), Empty);
|
map.insert(user_id.clone(), Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
let raw = raw::IgnoredUserListEventContent {
|
let raw = raw::IgnoredUserListEventContent { ignored_users: map };
|
||||||
ignored_users: map,
|
|
||||||
};
|
|
||||||
|
|
||||||
raw.serialize(serializer)
|
raw.serialize(serializer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod raw {
|
mod raw {
|
||||||
use crate::Empty;
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::Empty;
|
||||||
|
|
||||||
/// A list of users to ignore.
|
/// A list of users to ignore.
|
||||||
#[derive(Clone, Debug, Deserialize)]
|
#[derive(Clone, Debug, Deserialize)]
|
||||||
|
@ -7,9 +7,9 @@ use serde::{Deserialize, Serialize};
|
|||||||
pub mod accept;
|
pub mod accept;
|
||||||
pub mod cancel;
|
pub mod cancel;
|
||||||
pub mod key;
|
pub mod key;
|
||||||
pub mod mac;
|
// pub mod mac;
|
||||||
pub mod request;
|
pub mod request;
|
||||||
pub mod start;
|
// pub mod start;
|
||||||
|
|
||||||
/// A hash algorithm.
|
/// A hash algorithm.
|
||||||
#[derive(Clone, Copy, Debug, Serialize, PartialEq, Deserialize)]
|
#[derive(Clone, Copy, Debug, Serialize, PartialEq, Deserialize)]
|
||||||
|
@ -1,51 +1,51 @@
|
|||||||
//! Types for the *m.key.verification.accept* event.
|
//! Types for the *m.key.verification.accept* event.
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use ruma_events_macros::ruma_event;
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
HashAlgorithm, KeyAgreementProtocol, MessageAuthenticationCode, ShortAuthenticationString,
|
HashAlgorithm, KeyAgreementProtocol, MessageAuthenticationCode, ShortAuthenticationString,
|
||||||
VerificationMethod,
|
VerificationMethod,
|
||||||
};
|
};
|
||||||
|
|
||||||
event! {
|
ruma_event! {
|
||||||
/// Accepts a previously sent *m.key.verification.start* messge.
|
/// Accepts a previously sent *m.key.verification.start* messge.
|
||||||
///
|
///
|
||||||
/// Typically sent as a to-device event.
|
/// Typically sent as a to-device event.
|
||||||
pub struct AcceptEvent(AcceptEventContent) {}
|
AcceptEvent {
|
||||||
}
|
kind: Event,
|
||||||
|
event_type: KeyVerificationAccept,
|
||||||
/// The payload of an *m.key.verification.accept* event.
|
content: {
|
||||||
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
|
/// An opaque identifier for the verification process.
|
||||||
pub struct AcceptEventContent {
|
///
|
||||||
/// 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,
|
||||||
/// Must be the same as the one used for the *m.key.verification.start* message.
|
|
||||||
pub transaction_id: String,
|
/// The verification method to use.
|
||||||
|
///
|
||||||
/// The verification method to use.
|
/// Must be `m.sas.v1`.
|
||||||
///
|
pub method: VerificationMethod,
|
||||||
/// Must be `m.sas.v1`.
|
|
||||||
pub method: VerificationMethod,
|
/// The key agreement protocol the device is choosing to use, out of the options in the
|
||||||
|
/// *m.key.verification.start* message.
|
||||||
/// The key agreement protocol the device is choosing to use, out of the options in the
|
pub key_agreement_protocol: KeyAgreementProtocol,
|
||||||
/// *m.key.verification.start* message.
|
|
||||||
pub key_agreement_protocol: KeyAgreementProtocol,
|
/// The hash method the device is choosing to use, out of the options in the
|
||||||
|
/// *m.key.verification.start* message.
|
||||||
/// The hash method the device is choosing to use, out of the options in the
|
pub hash: HashAlgorithm,
|
||||||
/// *m.key.verification.start* message.
|
|
||||||
pub hash: HashAlgorithm,
|
/// The message authentication code the device is choosing to use, out of the options in the
|
||||||
|
/// *m.key.verification.start* message.
|
||||||
/// The message authentication code the device is choosing to use, out of the options in the
|
pub message_authentication_code: MessageAuthenticationCode,
|
||||||
/// *m.key.verification.start* message.
|
|
||||||
pub message_authentication_code: MessageAuthenticationCode,
|
/// The SAS methods both devices involved in the verification process understand.
|
||||||
|
///
|
||||||
/// The SAS methods both devices involved in the verification process understand.
|
/// Must be a subset of the options in the *m.key.verification.start* message.
|
||||||
///
|
pub short_authentication_string: Vec<ShortAuthenticationString>,
|
||||||
/// Must be a subset of the options in the *m.key.verification.start* message.
|
|
||||||
pub short_authentication_string: Vec<ShortAuthenticationString>,
|
/// The hash (encoded as unpadded base64) of the concatenation of the device's ephemeral public
|
||||||
|
/// key (encoded as unpadded base64) and the canonical JSON representation of the
|
||||||
/// The hash (encoded as unpadded base64) of the concatenation of the device's ephemeral public
|
/// *m.key.verification.start* message.
|
||||||
/// key (encoded as unpadded base64) and the canonical JSON representation of the
|
pub commitment: String,
|
||||||
/// *m.key.verification.start* message.
|
},
|
||||||
pub commitment: String,
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,31 +2,32 @@
|
|||||||
|
|
||||||
use std::fmt::{Display, Formatter, Result as FmtResult};
|
use std::fmt::{Display, Formatter, Result as FmtResult};
|
||||||
|
|
||||||
|
use ruma_events_macros::ruma_event;
|
||||||
use serde::{
|
use serde::{
|
||||||
de::{Error as SerdeError, Visitor},
|
de::{Error as SerdeError, Visitor},
|
||||||
Deserialize, Deserializer, Serialize, Serializer,
|
Deserialize, Deserializer, Serialize, Serializer,
|
||||||
};
|
};
|
||||||
|
|
||||||
event! {
|
ruma_event! {
|
||||||
/// Cancels a key verification process/request.
|
/// Cancels a key verification process/request.
|
||||||
///
|
///
|
||||||
/// Typically sent as a to-device event.
|
/// Typically sent as a to-device event.
|
||||||
pub struct CancelEvent(CancelEventContent) {}
|
CancelEvent {
|
||||||
}
|
kind: Event,
|
||||||
|
event_type: KeyVerificationCancel,
|
||||||
|
content: {
|
||||||
|
/// The opaque identifier for the verification process/request.
|
||||||
|
pub transaction_id: String,
|
||||||
|
|
||||||
/// The payload of an *m.key.verification.cancel* event.
|
/// A human readable description of the `code`.
|
||||||
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
|
///
|
||||||
pub struct CancelEventContent {
|
/// The client should only rely on this string if it does not understand the `code`.
|
||||||
/// The opaque identifier for the verification process/request.
|
pub reason: String,
|
||||||
pub transaction_id: String,
|
|
||||||
|
|
||||||
/// A human readable description of the `code`.
|
/// The error code for why the process/request was cancelled by the user.
|
||||||
///
|
pub code: CancelCode,
|
||||||
/// The client should only rely on this string if it does not understand the `code`.
|
},
|
||||||
pub reason: String,
|
}
|
||||||
|
|
||||||
/// The error code for why the process/request was cancelled by the user.
|
|
||||||
pub code: CancelCode,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An error code for why the process/request was cancelled by the user.
|
/// An error code for why the process/request was cancelled by the user.
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
//! Types for the *m.key.verification.key* event.
|
//! Types for the *m.key.verification.key* event.
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use ruma_events_macros::ruma_event;
|
||||||
|
|
||||||
event! {
|
ruma_event! {
|
||||||
/// Sends the ephemeral public key for a device to the partner device.
|
/// Sends the ephemeral public key for a device to the partner device.
|
||||||
///
|
///
|
||||||
/// Typically sent as a to-device event.
|
/// Typically sent as a to-device event.
|
||||||
pub struct KeyEvent(KeyEventContent) {}
|
KeyEvent {
|
||||||
}
|
kind: Event,
|
||||||
|
event_type: KeyVerificationKey,
|
||||||
|
content: {
|
||||||
|
/// 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 of an *m.key.verification.key* event.
|
/// The device's ephemeral public key, encoded as unpadded Base64.
|
||||||
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
|
pub key: String,
|
||||||
pub struct KeyEventContent {
|
},
|
||||||
/// 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 device's ephemeral public key, encoded as unpadded Base64.
|
|
||||||
pub key: String,
|
|
||||||
}
|
}
|
||||||
|
@ -1,29 +1,29 @@
|
|||||||
//! Types for the *m.key.verification.mac* event.
|
//! Types for the *m.key.verification.mac* event.
|
||||||
|
|
||||||
|
use ruma_events_macros::ruma_event;
|
||||||
use ruma_signatures::SignatureSet;
|
use ruma_signatures::SignatureSet;
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
event! {
|
ruma_event! {
|
||||||
/// Sends the MAC of a device's key to the partner device.
|
/// Sends the MAC of a device's key to the partner device.
|
||||||
///
|
///
|
||||||
/// Typically sent as a to-device event.
|
/// Typically sent as a to-device event.
|
||||||
pub struct MacEvent(MacEventContent) {}
|
MacEvent {
|
||||||
}
|
kind: Event,
|
||||||
|
event_type: KeyVerificationMac,
|
||||||
/// The payload for an *m.key.verification.mac* event.
|
content: {
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
/// An opaque identifier for the verification process.
|
||||||
pub struct MacEventContent {
|
///
|
||||||
/// 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,
|
||||||
/// Must be the same as the one used for the *m.key.verification.start* message.
|
|
||||||
pub transaction_id: String,
|
/// A map of the key ID to the MAC of the key, using the algorithm in the verification process.
|
||||||
|
///
|
||||||
/// A map of the key ID to the MAC of the key, using the algorithm in the verification process.
|
/// The MAC is encoded as unpadded Base64.
|
||||||
///
|
pub mac: SignatureSet,
|
||||||
/// The MAC is encoded as unpadded Base64.
|
|
||||||
pub mac: SignatureSet,
|
/// The MAC of the comma-separated, sorted, list of key IDs given in the `mac` property, encoded
|
||||||
|
/// as unpadded Base64.
|
||||||
/// The MAC of the comma-separated, sorted, list of key IDs given in the `mac` property, encoded
|
pub keys: String,
|
||||||
/// as unpadded Base64.
|
},
|
||||||
pub keys: String,
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,35 +1,35 @@
|
|||||||
//! Types for the *m.key.verification.request* event.
|
//! Types for the *m.key.verification.request* event.
|
||||||
|
|
||||||
use js_int::UInt;
|
use js_int::UInt;
|
||||||
|
use ruma_events_macros::ruma_event;
|
||||||
use ruma_identifiers::DeviceId;
|
use ruma_identifiers::DeviceId;
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
use super::VerificationMethod;
|
use super::VerificationMethod;
|
||||||
|
|
||||||
event! {
|
ruma_event! {
|
||||||
/// Requests a key verification with another user's devices.
|
/// Requests a key verification with another user's devices.
|
||||||
///
|
///
|
||||||
/// Typically sent as a to-device event.
|
/// Typically sent as a to-device event.
|
||||||
pub struct RequestEvent(RequestEventContent) {}
|
RequestEvent {
|
||||||
}
|
kind: Event,
|
||||||
|
event_type: KeyVerificationRequest,
|
||||||
/// The payload of an *m.key.verification.request* event.
|
content: {
|
||||||
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
|
/// The device ID which is initiating the request.
|
||||||
pub struct RequestEventContent {
|
pub from_device: DeviceId,
|
||||||
/// The device ID which is initiating the request.
|
|
||||||
pub from_device: DeviceId,
|
/// An opaque identifier for the verification request.
|
||||||
|
///
|
||||||
/// An opaque identifier for the verification request.
|
/// Must be unique with respect to the devices involved.
|
||||||
///
|
pub transaction_id: String,
|
||||||
/// Must be unique with respect to the devices involved.
|
|
||||||
pub transaction_id: String,
|
/// The verification methods supported by the sender.
|
||||||
|
pub methods: Vec<VerificationMethod>,
|
||||||
/// The verification methods supported by the sender.
|
|
||||||
pub methods: Vec<VerificationMethod>,
|
/// The POSIX timestamp in milliseconds for when the request was made.
|
||||||
|
///
|
||||||
/// The POSIX timestamp in milliseconds for when the request was made.
|
/// If the request is in the future by more than 5 minutes or more than 10 minutes in
|
||||||
///
|
/// the past, the message should be ignored by the receiver.
|
||||||
/// If the request is in the future by more than 5 minutes or more than 10 minutes in the past,
|
pub timestamp: UInt,
|
||||||
/// the message should be ignored by the receiver.
|
},
|
||||||
pub timestamp: UInt,
|
}
|
||||||
}
|
}
|
||||||
|
83
src/lib.rs
83
src/lib.rs
@ -113,6 +113,10 @@ use serde::{
|
|||||||
};
|
};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
|
pub use custom::CustomEvent;
|
||||||
|
pub use custom_room::CustomRoomEvent;
|
||||||
|
pub use custom_state::CustomStateEvent;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod macros;
|
mod macros;
|
||||||
|
|
||||||
@ -127,12 +131,12 @@ pub mod dummy;
|
|||||||
pub mod forwarded_room_key;
|
pub mod forwarded_room_key;
|
||||||
pub mod fully_read;
|
pub mod fully_read;
|
||||||
pub mod ignored_user_list;
|
pub mod ignored_user_list;
|
||||||
// pub mod key;
|
pub mod key;
|
||||||
pub mod presence;
|
pub mod presence;
|
||||||
// pub mod push_rules;
|
// pub mod push_rules;
|
||||||
pub mod receipt;
|
pub mod receipt;
|
||||||
pub mod room;
|
pub mod room;
|
||||||
// pub mod room_key;
|
pub mod room_key;
|
||||||
pub mod room_key_request;
|
pub mod room_key_request;
|
||||||
pub mod sticker;
|
pub mod sticker;
|
||||||
// pub mod stripped;
|
// pub mod stripped;
|
||||||
@ -223,7 +227,7 @@ pub struct Empty;
|
|||||||
impl Serialize for Empty {
|
impl Serialize for Empty {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
S: Serializer
|
S: Serializer,
|
||||||
{
|
{
|
||||||
serializer.serialize_map(Some(0))?.end()
|
serializer.serialize_map(Some(0))?.end()
|
||||||
}
|
}
|
||||||
@ -232,11 +236,11 @@ impl Serialize for Empty {
|
|||||||
impl<'de> Deserialize<'de> for Empty {
|
impl<'de> Deserialize<'de> for Empty {
|
||||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
where
|
where
|
||||||
D: Deserializer<'de>
|
D: Deserializer<'de>,
|
||||||
{
|
{
|
||||||
struct EmptyMapVisitor;
|
struct EmptyMapVisitor;
|
||||||
|
|
||||||
impl <'de> Visitor<'de> for EmptyMapVisitor {
|
impl<'de> Visitor<'de> for EmptyMapVisitor {
|
||||||
type Value = Empty;
|
type Value = Empty;
|
||||||
|
|
||||||
fn expecting(&self, f: &mut Formatter) -> FmtResult {
|
fn expecting(&self, f: &mut Formatter) -> FmtResult {
|
||||||
@ -245,7 +249,7 @@ impl<'de> Deserialize<'de> for Empty {
|
|||||||
|
|
||||||
fn visit_map<A>(self, _map: A) -> Result<Self::Value, A::Error>
|
fn visit_map<A>(self, _map: A) -> Result<Self::Value, A::Error>
|
||||||
where
|
where
|
||||||
A: MapAccess<'de>
|
A: MapAccess<'de>,
|
||||||
{
|
{
|
||||||
Ok(Empty)
|
Ok(Empty)
|
||||||
}
|
}
|
||||||
@ -401,9 +405,6 @@ pub trait Event
|
|||||||
where
|
where
|
||||||
Self: Debug + Serialize,
|
Self: Debug + Serialize,
|
||||||
{
|
{
|
||||||
/// The type of the event.
|
|
||||||
const EVENT_TYPE: EventType;
|
|
||||||
|
|
||||||
/// The type of this event's `content` field.
|
/// The type of this event's `content` field.
|
||||||
type Content: Debug + Serialize;
|
type Content: Debug + Serialize;
|
||||||
|
|
||||||
@ -411,9 +412,7 @@ where
|
|||||||
fn content(&self) -> &Self::Content;
|
fn content(&self) -> &Self::Content;
|
||||||
|
|
||||||
/// The type of the event.
|
/// The type of the event.
|
||||||
fn event_type(&self) -> EventType {
|
fn event_type(&self) -> EventType;
|
||||||
Self::EVENT_TYPE
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An event within the context of a room.
|
/// An event within the context of a room.
|
||||||
@ -447,20 +446,56 @@ pub trait StateEvent: RoomEvent {
|
|||||||
fn state_key(&self) -> &str;
|
fn state_key(&self) -> &str;
|
||||||
}
|
}
|
||||||
|
|
||||||
// event! {
|
mod custom {
|
||||||
// /// A custom basic event not covered by the Matrix specification.
|
use ruma_events_macros::ruma_event;
|
||||||
// pub struct CustomEvent(Value) {}
|
use serde_json::Value;
|
||||||
// }
|
|
||||||
|
|
||||||
// room_event! {
|
ruma_event! {
|
||||||
// /// A custom room event not covered by the Matrix specification.
|
/// A custom basic event not covered by the Matrix specification.
|
||||||
// pub struct CustomRoomEvent(Value) {}
|
CustomEvent {
|
||||||
// }
|
kind: Event,
|
||||||
|
event_type: Custom,
|
||||||
|
content_type_alias: {
|
||||||
|
/// The payload for `CustomEvent`.
|
||||||
|
Value
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// state_event! {
|
mod custom_room {
|
||||||
// /// A custom state event not covered by the Matrix specification.
|
use ruma_events_macros::ruma_event;
|
||||||
// pub struct CustomStateEvent(Value) {}
|
use serde_json::Value;
|
||||||
// }
|
|
||||||
|
ruma_event! {
|
||||||
|
/// A custom room event not covered by the Matrix specification.
|
||||||
|
CustomRoomEvent {
|
||||||
|
kind: RoomEvent,
|
||||||
|
event_type: Custom,
|
||||||
|
content_type_alias: {
|
||||||
|
/// The payload for `CustomRoomEvent`.
|
||||||
|
Value
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mod custom_state {
|
||||||
|
use ruma_events_macros::ruma_event;
|
||||||
|
use serde_json::Value;
|
||||||
|
|
||||||
|
ruma_event! {
|
||||||
|
/// A custom state event not covered by the Matrix specification.
|
||||||
|
CustomStateEvent {
|
||||||
|
kind: StateEvent,
|
||||||
|
event_type: Custom,
|
||||||
|
content_type_alias: {
|
||||||
|
/// The payload for `CustomStateEvent`.
|
||||||
|
Value
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Display for EventType {
|
impl Display for EventType {
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
|
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
|
||||||
|
@ -1,31 +1,31 @@
|
|||||||
//! Types for the *m.room_key* event.
|
//! Types for the *m.room_key* event.
|
||||||
|
|
||||||
|
use ruma_events_macros::ruma_event;
|
||||||
use ruma_identifiers::RoomId;
|
use ruma_identifiers::RoomId;
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
use super::Algorithm;
|
use super::Algorithm;
|
||||||
|
|
||||||
event! {
|
ruma_event! {
|
||||||
/// This event type is used to exchange keys for end-to-end encryption.
|
/// This event type is used to exchange keys for end-to-end encryption.
|
||||||
///
|
///
|
||||||
/// Typically it is encrypted as an *m.room.encrypted* event, then sent as a to-device event.
|
/// Typically it is encrypted as an *m.room.encrypted* event, then sent as a to-device event.
|
||||||
pub struct RoomKeyEvent(RoomKeyEventContent) {}
|
RoomKeyEvent {
|
||||||
}
|
kind: Event,
|
||||||
|
event_type: RoomKey,
|
||||||
/// The payload of an *m.room_key* event.
|
content: {
|
||||||
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
|
/// The encryption algorithm the key in this event is to be used with.
|
||||||
pub struct RoomKeyEventContent {
|
///
|
||||||
/// The encryption algorithm the key in this event is to be used with.
|
/// Must be `m.megolm.v1.aes-sha2`.
|
||||||
///
|
pub algorithm: Algorithm,
|
||||||
/// Must be `m.megolm.v1.aes-sha2`.
|
|
||||||
pub algorithm: Algorithm,
|
/// The room where the key is used.
|
||||||
|
pub room_id: RoomId,
|
||||||
/// The room where the key is used.
|
|
||||||
pub room_id: RoomId,
|
/// The ID of the session that the key is for.
|
||||||
|
pub session_id: String,
|
||||||
/// The ID of the session that the key is for.
|
|
||||||
pub session_id: String,
|
/// The key to be exchanged.
|
||||||
|
pub session_key: String,
|
||||||
/// The key to be exchanged.
|
}
|
||||||
pub session_key: String,
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user