client-api: Move support for room type out of unstable-pre-spec

This commit is contained in:
Kévin Commaille 2022-02-11 11:28:51 +01:00 committed by GitHub
parent 203e5136fd
commit 7a82fc0330
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 30 deletions

View File

@ -44,6 +44,7 @@ Improvements:
* The `r0::session::get_login_types::{IdentityProvider, IdentityProviderBrand}` types * The `r0::session::get_login_types::{IdentityProvider, IdentityProviderBrand}` types
* The `session::sso_login_with_provider::v3` endpoint * The `session::sso_login_with_provider::v3` endpoint
* Move reason support for leaving room out of `unstable-pre-spec` * Move reason support for leaving room out of `unstable-pre-spec`
* Move room type support out of `unstable-pre-spec`
# 0.12.3 # 0.12.3

View File

@ -2,11 +2,9 @@
use assign::assign; use assign::assign;
use ruma_api::ruma_api; use ruma_api::ruma_api;
#[cfg(feature = "unstable-pre-spec")]
use ruma_events::room::create::RoomType;
use ruma_events::{ use ruma_events::{
room::{ room::{
create::{PreviousRoom, RoomCreateEventContent}, create::{PreviousRoom, RoomCreateEventContent, RoomType},
power_levels::RoomPowerLevelsEventContent, power_levels::RoomPowerLevelsEventContent,
}, },
AnyInitialStateEvent, AnyInitialStateEvent,
@ -139,7 +137,6 @@ pub struct CreationContent {
/// The room type. /// The room type.
/// ///
/// This is currently only used for spaces. /// This is currently only used for spaces.
#[cfg(feature = "unstable-pre-spec")]
#[serde(skip_serializing_if = "Option::is_none", rename = "type")] #[serde(skip_serializing_if = "Option::is_none", rename = "type")]
pub room_type: Option<RoomType>, pub room_type: Option<RoomType>,
} }
@ -147,12 +144,7 @@ pub struct CreationContent {
impl CreationContent { impl CreationContent {
/// Creates a new `CreationContent` with all fields defaulted. /// Creates a new `CreationContent` with all fields defaulted.
pub fn new() -> Self { pub fn new() -> Self {
Self { Self { federate: true, predecessor: None, room_type: None }
federate: true,
predecessor: None,
#[cfg(feature = "unstable-pre-spec")]
room_type: None,
}
} }
/// Given a `CreationContent` and the other fields that a homeserver has to fill, construct /// Given a `CreationContent` and the other fields that a homeserver has to fill, construct
@ -162,33 +154,17 @@ impl CreationContent {
creator: Box<UserId>, creator: Box<UserId>,
room_version: RoomVersionId, room_version: RoomVersionId,
) -> RoomCreateEventContent { ) -> RoomCreateEventContent {
#[allow(unused_mut)] assign!(RoomCreateEventContent::new(creator), {
let mut content = assign!(RoomCreateEventContent::new(creator), {
federate: self.federate, federate: self.federate,
room_version: room_version, room_version: room_version,
predecessor: self.predecessor, predecessor: self.predecessor,
}); room_type: self.room_type
})
#[cfg(feature = "unstable-pre-spec")]
{
content.room_type = self.room_type;
}
content
} }
/// Returns whether all fields have their default value. /// Returns whether all fields have their default value.
pub fn is_empty(&self) -> bool { pub fn is_empty(&self) -> bool {
let stable_fields = self.federate && self.predecessor.is_none(); self.federate && self.predecessor.is_none() && self.room_type.is_none()
#[cfg(feature = "unstable-pre-spec")]
{
stable_fields && self.room_type.is_none()
}
#[cfg(not(feature = "unstable-pre-spec"))]
{
stable_fields
}
} }
} }