Bring back direct, dummy, push_rules
This commit is contained in:
parent
63a2e5e4eb
commit
924ff5096b
@ -1,5 +1,17 @@
|
|||||||
use ruma_events_macros::event_content_enum;
|
use ruma_events_macros::event_content_enum;
|
||||||
|
|
||||||
|
event_content_enum! {
|
||||||
|
/// A basic event.
|
||||||
|
name: AnyBasicEventContent,
|
||||||
|
events: [
|
||||||
|
"m.direct",
|
||||||
|
"m.dummy",
|
||||||
|
"m.ignored_user_list",
|
||||||
|
"m.push_rules",
|
||||||
|
"m.room_key",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
event_content_enum! {
|
event_content_enum! {
|
||||||
/// Any message event's content.
|
/// Any message event's content.
|
||||||
name: AnyMessageEventContent,
|
name: AnyMessageEventContent,
|
||||||
@ -40,9 +52,3 @@ event_content_enum! {
|
|||||||
name: AnyEphemeralRoomEventContent,
|
name: AnyEphemeralRoomEventContent,
|
||||||
events: [ "m.typing", "m.receipt" ]
|
events: [ "m.typing", "m.receipt" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
event_content_enum! {
|
|
||||||
/// A basic event.
|
|
||||||
name: AnyBasicEventContent,
|
|
||||||
events: [ "m.ignored_user_list", "m.room_key" ]
|
|
||||||
}
|
|
||||||
|
@ -1,22 +1,36 @@
|
|||||||
//! Types for the *m.direct* event.
|
//! Types for the *m.direct* event.
|
||||||
|
|
||||||
use std::collections::BTreeMap;
|
use std::{
|
||||||
|
collections::BTreeMap,
|
||||||
|
ops::{Deref, DerefMut},
|
||||||
|
};
|
||||||
|
|
||||||
use ruma_events_macros::ruma_event;
|
use ruma_events_macros::BasicEventContent;
|
||||||
use ruma_identifiers::{RoomId, UserId};
|
use ruma_identifiers::{RoomId, UserId};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
ruma_event! {
|
/// Informs the client about the rooms that are considered direct by a user.
|
||||||
/// Informs the client about the rooms that are considered direct by a user.
|
pub type DirectEvent = crate::BasicEvent<DirectEventContent>;
|
||||||
DirectEvent {
|
|
||||||
kind: Event,
|
/// The payload for `DirectEvent`.
|
||||||
event_type: "m.direct",
|
///
|
||||||
content_type_alias: {
|
/// A mapping of `UserId`s to a list of `RoomId`s which are considered *direct* for that
|
||||||
/// The payload for `DirectEvent`.
|
/// particular user.
|
||||||
///
|
#[derive(Clone, Debug, Deserialize, Serialize, BasicEventContent)]
|
||||||
/// A mapping of `UserId`s to a list of `RoomId`s which are considered *direct* for that
|
#[ruma_event(type = "m.direct")]
|
||||||
/// particular user.
|
pub struct DirectEventContent(pub BTreeMap<UserId, Vec<RoomId>>);
|
||||||
BTreeMap<UserId, Vec<RoomId>>
|
|
||||||
},
|
impl Deref for DirectEventContent {
|
||||||
|
type Target = BTreeMap<UserId, Vec<RoomId>>;
|
||||||
|
|
||||||
|
fn deref(&self) -> &Self::Target {
|
||||||
|
&self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl DerefMut for DirectEventContent {
|
||||||
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||||
|
&mut self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,7 +46,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn serialization() {
|
fn serialization() {
|
||||||
let mut content: DirectEventContent = BTreeMap::new();
|
let mut content = DirectEventContent(BTreeMap::new());
|
||||||
let alice = UserId::new("ruma.io").unwrap();
|
let alice = UserId::new("ruma.io").unwrap();
|
||||||
let room = vec![RoomId::new("ruma.io").unwrap()];
|
let room = vec![RoomId::new("ruma.io").unwrap()];
|
||||||
|
|
||||||
|
57
src/dummy.rs
57
src/dummy.rs
@ -1,38 +1,55 @@
|
|||||||
//! Types for the *m.dummy* event.
|
//! Types for the *m.dummy* event.
|
||||||
|
|
||||||
use ruma_events_macros::ruma_event;
|
use std::ops::{Deref, DerefMut};
|
||||||
use ruma_serde::empty::Empty;
|
|
||||||
|
|
||||||
ruma_event! {
|
use ruma_events_macros::BasicEventContent;
|
||||||
/// This event type is used to indicate new Olm sessions for end-to-end encryption.
|
use ruma_serde::empty::Empty;
|
||||||
///
|
use serde::{Deserialize, Serialize};
|
||||||
/// Typically it is encrypted as an *m.room.encrypted* event, then sent as a to-device event.
|
|
||||||
///
|
use crate::BasicEvent;
|
||||||
/// The event does not have any content associated with it. The sending client is expected to
|
|
||||||
/// send a key share request shortly after this message, causing the receiving client to process
|
/// This event type is used to indicate new Olm sessions for end-to-end encryption.
|
||||||
/// this *m.dummy* event as the most recent event and using the keyshare request to set up the
|
///
|
||||||
/// session. The keyshare request and *m.dummy* combination should result in the original
|
/// Typically it is encrypted as an *m.room.encrypted* event, then sent as a to-device event.
|
||||||
/// sending client receiving keys over the newly established session.
|
///
|
||||||
DummyEvent {
|
/// The event does not have any content associated with it. The sending client is expected to
|
||||||
kind: Event,
|
/// send a key share request shortly after this message, causing the receiving client to process
|
||||||
event_type: "m.dummy",
|
/// this *m.dummy* event as the most recent event and using the keyshare request to set up the
|
||||||
content_type_alias: {
|
/// session. The keyshare request and *m.dummy* combination should result in the original
|
||||||
/// The payload for `DummyEvent`.
|
/// sending client receiving keys over the newly established session.
|
||||||
Empty
|
pub type DummyEvent = BasicEvent<DummyEventContent>;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Deserialize, Serialize, BasicEventContent)]
|
||||||
|
#[ruma_event(type = "m.dummy")]
|
||||||
|
/// The payload for `DummyEvent`.
|
||||||
|
pub struct DummyEventContent(pub Empty);
|
||||||
|
|
||||||
|
impl Deref for DummyEventContent {
|
||||||
|
type Target = Empty;
|
||||||
|
|
||||||
|
fn deref(&self) -> &Self::Target {
|
||||||
|
&self.0
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl DerefMut for DummyEventContent {
|
||||||
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||||
|
&mut self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::{DummyEvent, Empty};
|
use super::{DummyEvent, DummyEventContent, Empty};
|
||||||
use crate::EventJson;
|
use crate::EventJson;
|
||||||
|
|
||||||
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
|
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn serialization() {
|
fn serialization() {
|
||||||
let dummy_event = DummyEvent { content: Empty };
|
let dummy_event = DummyEvent {
|
||||||
|
content: DummyEventContent(Empty),
|
||||||
|
};
|
||||||
let actual = to_json_value(dummy_event).unwrap();
|
let actual = to_json_value(dummy_event).unwrap();
|
||||||
|
|
||||||
let expected = json!({
|
let expected = json!({
|
||||||
|
@ -145,14 +145,14 @@ extern crate self as ruma_events;
|
|||||||
|
|
||||||
pub mod call;
|
pub mod call;
|
||||||
pub mod custom;
|
pub mod custom;
|
||||||
// pub mod direct;
|
pub mod direct;
|
||||||
// pub mod dummy;
|
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;
|
||||||
|
@ -1,18 +1,19 @@
|
|||||||
//! Types for the the *m.push_rules* event.
|
//! Types for the the *m.push_rules* event.
|
||||||
|
|
||||||
use ruma_events_macros::ruma_event;
|
use ruma_events_macros::BasicEventContent;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
ruma_event! {
|
use crate::BasicEvent;
|
||||||
/// Describes all push rules for a user.
|
|
||||||
PushRulesEvent {
|
/// Describes all push rules for a user.
|
||||||
kind: Event,
|
pub type PushRulesEvent = BasicEvent<PushRulesEventContent>;
|
||||||
event_type: "m.push_rules",
|
|
||||||
content: {
|
/// The payload for `PushRulesEvent`.
|
||||||
|
#[derive(Clone, Debug, Deserialize, Serialize, BasicEventContent)]
|
||||||
|
#[ruma_event(type = "m.push_rules")]
|
||||||
|
pub struct PushRulesEventContent {
|
||||||
/// The global ruleset.
|
/// The global ruleset.
|
||||||
pub global: Ruleset,
|
pub global: Ruleset,
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub use ruma_common::push::Action;
|
pub use ruma_common::push::Action;
|
||||||
@ -153,7 +154,7 @@ mod tests {
|
|||||||
use matches::assert_matches;
|
use matches::assert_matches;
|
||||||
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
|
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
|
||||||
|
|
||||||
use super::PushCondition;
|
use super::{PushCondition, PushRulesEvent};
|
||||||
use crate::EventJson;
|
use crate::EventJson;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user