client-api: Use Raw for create_room::Request::creation_content
This commit is contained in:
parent
401c0b07b3
commit
e7f01ca55a
@ -8,6 +8,7 @@ Breaking changes:
|
|||||||
nested borrowing can be very annoying
|
nested borrowing can be very annoying
|
||||||
* `LoginInfo` no longer implements `PartialEq` and `Eq` due to the custom variant that was added.
|
* `LoginInfo` no longer implements `PartialEq` and `Eq` due to the custom variant that was added.
|
||||||
* `LoginInfo` converted to newtype variants.
|
* `LoginInfo` converted to newtype variants.
|
||||||
|
* Use `Raw` for `create_room::Request::creation_content`
|
||||||
|
|
||||||
Improvements:
|
Improvements:
|
||||||
|
|
||||||
|
@ -31,8 +31,8 @@ ruma_api! {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
request: {
|
request: {
|
||||||
/// Extra keys to be added to the content of the `m.room.create`.
|
/// Extra keys to be added to the content of the `m.room.create`.
|
||||||
#[serde(default, skip_serializing_if = "CreationContent::is_empty")]
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
pub creation_content: CreationContent,
|
pub creation_content: Option<Raw<CreationContent>>,
|
||||||
|
|
||||||
/// List of state events to send to the new room.
|
/// List of state events to send to the new room.
|
||||||
///
|
///
|
||||||
|
@ -239,17 +239,19 @@ impl<'de> Deserialize<'de> for AllowRule {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#[cfg(feature = "unstable-pre-spec")]
|
use matches::assert_matches;
|
||||||
use super::AllowRule;
|
|
||||||
use super::{JoinRule, RoomJoinRulesEventContent};
|
|
||||||
#[cfg(feature = "unstable-pre-spec")]
|
#[cfg(feature = "unstable-pre-spec")]
|
||||||
use ruma_identifiers::room_id;
|
use ruma_identifiers::room_id;
|
||||||
|
|
||||||
|
#[cfg(feature = "unstable-pre-spec")]
|
||||||
|
use super::AllowRule;
|
||||||
|
use super::{JoinRule, RoomJoinRulesEvent, RoomJoinRulesEventContent};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn deserialize() {
|
fn deserialize() {
|
||||||
let json = r#"{"join_rule": "public"}"#;
|
let json = r#"{"join_rule": "public"}"#;
|
||||||
let event: RoomJoinRulesEventContent = serde_json::from_str(json).unwrap();
|
let event: RoomJoinRulesEventContent = serde_json::from_str(json).unwrap();
|
||||||
assert!(matches!(event, RoomJoinRulesEventContent { join_rule: JoinRule::Public }));
|
assert_matches!(event, RoomJoinRulesEventContent { join_rule: JoinRule::Public });
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "unstable-pre-spec")]
|
#[cfg(feature = "unstable-pre-spec")]
|
||||||
@ -280,4 +282,25 @@ mod tests {
|
|||||||
rule => panic!("Deserialized to wrong variant: {:?}", rule),
|
rule => panic!("Deserialized to wrong variant: {:?}", rule),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn deserialize_restricted_event() {
|
||||||
|
let json = r#"{
|
||||||
|
"type": "m.room.join_rules",
|
||||||
|
"sender": "@admin:community.rs",
|
||||||
|
"content": {
|
||||||
|
"join_rule": "restricted",
|
||||||
|
"allow":[
|
||||||
|
{ "type": "m.room_membership","room_id": "!KqeUnzmXPIhHRaWMTs:mccarty.io" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"state_key": "",
|
||||||
|
"origin_server_ts":1630508835342,
|
||||||
|
"unsigned": {
|
||||||
|
"age":4165521871
|
||||||
|
},
|
||||||
|
"event_id": "$0ACb9KSPlT3al3kikyRYvFhMqXPP9ZcQOBrsdIuh58U"
|
||||||
|
}"#;
|
||||||
|
|
||||||
|
assert_matches!(serde_json::from_str::<RoomJoinRulesEvent>(json), Ok(_));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user