fix: ruma

This commit is contained in:
Timo Kösters 2021-07-15 19:54:04 +02:00
parent d07762f596
commit 0fcefa4125
No known key found for this signature in database
GPG key ID: 24DA7517711A2BA4
8 changed files with 115 additions and 66 deletions

View file

@ -9,7 +9,11 @@ use ruma::{
r0::room::{self, create_room, get_room_event, upgrade_room},
},
events::{
room::{guest_access, history_visibility, join_rules, member, name, topic},
room::{
guest_access, history_visibility, join_rules, member,
name::{self, RoomName},
topic,
},
EventType,
},
serde::Raw,
@ -113,7 +117,7 @@ pub async fn create_room_route(
.unwrap_or_else(|| match &body.visibility {
room::Visibility::Private => create_room::RoomPreset::PrivateChat,
room::Visibility::Public => create_room::RoomPreset::PublicChat,
room::Visibility::_Custom(_) => create_room::RoomPreset::PrivateChat, // Room visibility should not be custom
_ => create_room::RoomPreset::PrivateChat, // Room visibility should not be custom
});
let mut users = BTreeMap::new();
@ -251,11 +255,11 @@ pub async fn create_room_route(
db.rooms.build_and_append_pdu(
PduBuilder {
event_type: EventType::RoomName,
content: serde_json::to_value(
name::NameEventContent::new(name.clone()).map_err(|_| {
content: serde_json::to_value(name::NameEventContent::new(Some(
RoomName::try_from(name.clone()).map_err(|_| {
Error::BadRequest(ErrorKind::InvalidParam, "Name is invalid.")
})?,
)
)))
.expect("event is valid, we just created it"),
unsigned: None,
state_key: Some("".to_owned()),