diff --git a/crates/ruma-client-api/CHANGELOG.md b/crates/ruma-client-api/CHANGELOG.md index 554e5676..a0949dc2 100644 --- a/crates/ruma-client-api/CHANGELOG.md +++ b/crates/ruma-client-api/CHANGELOG.md @@ -44,6 +44,7 @@ Improvements: * The `r0::session::get_login_types::{IdentityProvider, IdentityProviderBrand}` types * The `session::sso_login_with_provider::v3` endpoint * Move reason support for leaving room out of `unstable-pre-spec` +* Move room type support out of `unstable-pre-spec` # 0.12.3 diff --git a/crates/ruma-client-api/src/r0/room/create_room.rs b/crates/ruma-client-api/src/r0/room/create_room.rs index e8fa10df..4c1a37c5 100644 --- a/crates/ruma-client-api/src/r0/room/create_room.rs +++ b/crates/ruma-client-api/src/r0/room/create_room.rs @@ -2,11 +2,9 @@ use assign::assign; use ruma_api::ruma_api; -#[cfg(feature = "unstable-pre-spec")] -use ruma_events::room::create::RoomType; use ruma_events::{ room::{ - create::{PreviousRoom, RoomCreateEventContent}, + create::{PreviousRoom, RoomCreateEventContent, RoomType}, power_levels::RoomPowerLevelsEventContent, }, AnyInitialStateEvent, @@ -139,7 +137,6 @@ pub struct CreationContent { /// The room type. /// /// This is currently only used for spaces. - #[cfg(feature = "unstable-pre-spec")] #[serde(skip_serializing_if = "Option::is_none", rename = "type")] pub room_type: Option, } @@ -147,12 +144,7 @@ pub struct CreationContent { impl CreationContent { /// Creates a new `CreationContent` with all fields defaulted. pub fn new() -> Self { - Self { - federate: true, - predecessor: None, - #[cfg(feature = "unstable-pre-spec")] - room_type: None, - } + Self { federate: true, predecessor: None, room_type: None } } /// Given a `CreationContent` and the other fields that a homeserver has to fill, construct @@ -162,33 +154,17 @@ impl CreationContent { creator: Box, room_version: RoomVersionId, ) -> RoomCreateEventContent { - #[allow(unused_mut)] - let mut content = assign!(RoomCreateEventContent::new(creator), { + assign!(RoomCreateEventContent::new(creator), { federate: self.federate, room_version: room_version, predecessor: self.predecessor, - }); - - #[cfg(feature = "unstable-pre-spec")] - { - content.room_type = self.room_type; - } - - content + room_type: self.room_type + }) } /// Returns whether all fields have their default value. pub fn is_empty(&self) -> bool { - let stable_fields = self.federate && self.predecessor.is_none(); - - #[cfg(feature = "unstable-pre-spec")] - { - stable_fields && self.room_type.is_none() - } - #[cfg(not(feature = "unstable-pre-spec"))] - { - stable_fields - } + self.federate && self.predecessor.is_none() && self.room_type.is_none() } }