From 0f49c5e7f65f72857a36a8d7e81dd77f5309849e Mon Sep 17 00:00:00 2001 From: Jimmy Cuadra Date: Sat, 22 Jun 2019 00:10:03 -0700 Subject: [PATCH] Convert m.room.create to the new API. --- src/room.rs | 2 +- src/room/canonical_alias.rs | 2 +- src/room/create.rs | 38 ++++++++++++++++++------------------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/room.rs b/src/room.rs index 37439530..222a9f23 100644 --- a/src/room.rs +++ b/src/room.rs @@ -10,7 +10,7 @@ use serde::{Deserialize, Serialize}; pub mod aliases; pub mod avatar; pub mod canonical_alias; -// pub mod create; +pub mod create; // pub mod encrypted; pub mod encryption; pub mod guest_access; diff --git a/src/room/canonical_alias.rs b/src/room/canonical_alias.rs index 7ea8696d..6a581c19 100644 --- a/src/room/canonical_alias.rs +++ b/src/room/canonical_alias.rs @@ -40,7 +40,7 @@ pub struct CanonicalAliasEvent { pub unsigned: Option, } -/// The payload of a `CanonicalAliasEvent`. +/// The payload for `CanonicalAliasEvent`. #[derive(Clone, Debug, PartialEq, Serialize)] pub struct CanonicalAliasEventContent { /// The canonical alias. diff --git a/src/room/create.rs b/src/room/create.rs index 0a5acd55..6339871b 100644 --- a/src/room/create.rs +++ b/src/room/create.rs @@ -2,35 +2,35 @@ use std::convert::TryFrom; -use js_int::UInt; +use ruma_events_macros::ruma_event; use ruma_identifiers::{EventId, RoomId, RoomVersionId, UserId}; use serde::{Deserialize, Serialize}; use crate::default_true; -state_event! { +ruma_event! { /// This is the first event in a room and cannot be changed. It acts as the root of all other /// events. - pub struct CreateEvent(CreateEventContent) {} -} + CreateEvent { + kind: StateEvent, + event_type: RoomCreate, + content: { + /// The `user_id` of the room creator. This is set by the homeserver. + pub creator: UserId, -/// The payload of a `CreateEvent`. -#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] -pub struct CreateEventContent { - /// The `user_id` of the room creator. This is set by the homeserver. - pub creator: UserId, + /// Whether or not this room's data should be transferred to other homeservers. + #[serde(rename = "m.federate")] + #[serde(default = "default_true")] + pub federate: bool, - /// Whether or not this room's data should be transferred to other homeservers. - #[serde(rename = "m.federate")] - #[serde(default = "default_true")] - pub federate: bool, + /// The version of the room. Defaults to "1" if the key does not exist. + #[serde(default = "default_room_version_id")] + pub room_version: RoomVersionId, - /// The version of the room. Defaults to "1" if the key does not exist. - #[serde(default = "default_room_version_id")] - pub room_version: RoomVersionId, - - /// A reference to the room this room replaces, if the previous room was upgraded. - pub predecessor: Option, + /// A reference to the room this room replaces, if the previous room was upgraded. + pub predecessor: Option, + }, + } } /// A reference to an old room replaced during a room version upgrade.