Add kind = ToDevice for all to device content
This commit is contained in:
parent
b6558c64a0
commit
058d2bfa24
@ -680,6 +680,18 @@ fn marker_traits(kind: &EventKind, ruma_events: &TokenStream) -> TokenStream {
|
||||
#[automatically_derived]
|
||||
impl #ruma_events::EphemeralRoomEventContent for #ident {}
|
||||
},
|
||||
EventKind::GlobalAccountData => quote! {
|
||||
#[automatically_derived]
|
||||
impl #ruma_events::GlobalAccountDataEventContent for #ident {}
|
||||
},
|
||||
EventKind::RoomAccountData => quote! {
|
||||
#[automatically_derived]
|
||||
impl #ruma_events::RoomAccountDataEventContent for #ident {}
|
||||
},
|
||||
EventKind::ToDevice => quote! {
|
||||
#[automatically_derived]
|
||||
impl #ruma_events::ToDeviceEventContent for #ident {}
|
||||
},
|
||||
_ => TokenStream::new(),
|
||||
}
|
||||
}
|
||||
|
@ -15,5 +15,5 @@ use serde::{Deserialize, Serialize};
|
||||
/// session. The keyshare request and *m.dummy* combination should result in the original
|
||||
/// sending client receiving keys over the newly established session.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
|
||||
#[ruma_event(type = "m.dummy")]
|
||||
#[ruma_event(type = "m.dummy", kind = ToDevice)]
|
||||
pub struct DummyToDeviceEventContent {}
|
||||
|
@ -3,9 +3,9 @@ use ruma_events_macros::Event;
|
||||
use ruma_identifiers::{EventId, RoomId, UserId};
|
||||
|
||||
use crate::{
|
||||
EphemeralRoomEventContent, EventContent, GlobalAccountDataEventContent, MessageEventContent,
|
||||
EphemeralRoomEventContent, GlobalAccountDataEventContent, MessageEventContent,
|
||||
RedactedMessageEventContent, RedactedStateEventContent, RedactedSyncUnsigned, RedactedUnsigned,
|
||||
RoomAccountDataEventContent, StateEventContent, Unsigned,
|
||||
RoomAccountDataEventContent, StateEventContent, ToDeviceEventContent, Unsigned,
|
||||
};
|
||||
|
||||
/// A global account data event.
|
||||
@ -318,7 +318,7 @@ pub struct RedactedStrippedStateEvent<C: RedactedStateEventContent> {
|
||||
|
||||
/// An event sent using send-to-device messaging.
|
||||
#[derive(Clone, Debug, Event)]
|
||||
pub struct ToDeviceEvent<C: EventContent> {
|
||||
pub struct ToDeviceEvent<C: ToDeviceEventContent> {
|
||||
/// Data specific to the event type.
|
||||
pub content: C,
|
||||
|
||||
|
@ -10,7 +10,7 @@ use serde::{Deserialize, Serialize};
|
||||
/// and convert it via `ForwardedRoomKeyToDeviceEventContent::from` / `.into()`.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
#[ruma_event(type = "m.forwarded_room_key")]
|
||||
#[ruma_event(type = "m.forwarded_room_key", kind = ToDevice)]
|
||||
pub struct ForwardedRoomKeyToDeviceEventContent {
|
||||
/// The encryption algorithm the key in this event is to be used with.
|
||||
pub algorithm: EventEncryptionAlgorithm,
|
||||
|
@ -21,7 +21,7 @@ pub type AcceptEvent = MessageEvent<AcceptEventContent>;
|
||||
|
||||
/// The payload for a to-device `AcceptEvent`.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
|
||||
#[ruma_event(type = "m.key.verification.accept")]
|
||||
#[ruma_event(type = "m.key.verification.accept", kind = ToDevice)]
|
||||
pub struct AcceptToDeviceEventContent {
|
||||
/// An opaque identifier for the verification process.
|
||||
///
|
||||
|
@ -16,7 +16,7 @@ pub type CancelEvent = MessageEvent<CancelEventContent>;
|
||||
|
||||
/// The payload for a to-device `CancelEvent`.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
|
||||
#[ruma_event(type = "m.key.verification.cancel")]
|
||||
#[ruma_event(type = "m.key.verification.cancel", kind = ToDevice)]
|
||||
pub struct CancelToDeviceEventContent {
|
||||
/// The opaque identifier for the verification process/request.
|
||||
pub transaction_id: String,
|
||||
|
@ -12,7 +12,7 @@ pub type DoneEvent = MessageEvent<DoneEventContent>;
|
||||
|
||||
/// The payload for a to-device `m.key.verification.done` event.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
|
||||
#[ruma_event(type = "m.key.verification.done")]
|
||||
#[ruma_event(type = "m.key.verification.done", kind = ToDevice)]
|
||||
pub struct DoneToDeviceEventContent {
|
||||
/// An opaque identifier for the verification process.
|
||||
///
|
||||
|
@ -15,7 +15,7 @@ pub type KeyEvent = MessageEvent<KeyEventContent>;
|
||||
|
||||
/// The payload for a to-device `KeyEvent`.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
|
||||
#[ruma_event(type = "m.key.verification.key")]
|
||||
#[ruma_event(type = "m.key.verification.key", kind = ToDevice)]
|
||||
pub struct KeyToDeviceEventContent {
|
||||
/// An opaque identifier for the verification process.
|
||||
///
|
||||
|
@ -17,7 +17,7 @@ pub type MacEvent = MessageEvent<MacEventContent>;
|
||||
|
||||
/// The payload for a to-device `MacEvent`.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
|
||||
#[ruma_event(type = "m.key.verification.mac")]
|
||||
#[ruma_event(type = "m.key.verification.mac", kind = ToDevice)]
|
||||
pub struct MacToDeviceEventContent {
|
||||
/// An opaque identifier for the verification process.
|
||||
///
|
||||
|
@ -12,7 +12,7 @@ pub type ReadyEvent = MessageEvent<ReadyEventContent>;
|
||||
|
||||
/// The payload for a to-device `m.key.verification.ready` event.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
|
||||
#[ruma_event(type = "m.key.verification.ready")]
|
||||
#[ruma_event(type = "m.key.verification.ready", kind = ToDevice)]
|
||||
pub struct ReadyToDeviceEventContent {
|
||||
/// The device ID which is initiating the request.
|
||||
pub from_device: DeviceIdBox,
|
||||
|
@ -9,7 +9,7 @@ use super::VerificationMethod;
|
||||
|
||||
/// The payload for `RequestEvent`.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
|
||||
#[ruma_event(type = "m.key.verification.request")]
|
||||
#[ruma_event(type = "m.key.verification.request", kind = ToDevice)]
|
||||
pub struct RequestToDeviceEventContent {
|
||||
/// The device ID which is initiating the request.
|
||||
pub from_device: DeviceIdBox,
|
||||
|
@ -23,7 +23,7 @@ pub type StartEvent = MessageEvent<StartEventContent>;
|
||||
|
||||
/// The payload of a to-device *m.key.verification.start* event.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
|
||||
#[ruma_event(type = "m.key.verification.start")]
|
||||
#[ruma_event(type = "m.key.verification.start", kind = ToDevice)]
|
||||
pub struct StartToDeviceEventContent {
|
||||
/// The device ID which is initiating the process.
|
||||
pub from_device: DeviceIdBox,
|
||||
|
@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize};
|
||||
///
|
||||
/// Typically encrypted as an *m.room.encrypted* event, then sent as a to-device event.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
|
||||
#[ruma_event(type = "m.room_key")]
|
||||
#[ruma_event(type = "m.room_key", kind = ToDevice)]
|
||||
pub struct RoomKeyToDeviceEventContent {
|
||||
/// The encryption algorithm the key in this event is to be used with.
|
||||
///
|
||||
|
@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
/// The payload for `RoomKeyRequestEvent`.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
|
||||
#[ruma_event(type = "m.room_key_request")]
|
||||
#[ruma_event(type = "m.room_key_request", kind = ToDevice)]
|
||||
pub struct RoomKeyRequestToDeviceEventContent {
|
||||
/// Whether this is a new key request or a cancellation of a previous request.
|
||||
pub action: Action,
|
||||
|
@ -15,7 +15,7 @@ fn serialization() {
|
||||
};
|
||||
|
||||
assert_eq!(
|
||||
to_json_value(ev).unwrap(),
|
||||
to_json_value(&ev).unwrap(),
|
||||
json!({
|
||||
"type": "m.room_key",
|
||||
"sender": "@example:example.org",
|
||||
|
Loading…
x
Reference in New Issue
Block a user