From 989a20e99ce1ddbc7fb179b69ef3358d15d040b6 Mon Sep 17 00:00:00 2001 From: Kurt Roeckx Date: Sat, 7 Aug 2021 15:55:03 +0200 Subject: [PATCH] Support creating rooms with a version --- src/client_server/room.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/client_server/room.rs b/src/client_server/room.rs index f73d544..cc7dba6 100644 --- a/src/client_server/room.rs +++ b/src/client_server/room.rs @@ -65,7 +65,19 @@ pub async fn create_room_route( let mut content = ruma::events::room::create::CreateEventContent::new(sender_user.clone()); content.federate = body.creation_content.federate; content.predecessor = body.creation_content.predecessor.clone(); - content.room_version = RoomVersionId::Version6; + content.room_version = match body.room_version.clone() { + Some(room_version) => { + if room_version == RoomVersionId::Version5 || room_version == RoomVersionId::Version6 { + room_version + } else { + return Err(Error::BadRequest( + ErrorKind::UnsupportedRoomVersion, + "This server does not support that room version.", + )); + } + } + None => RoomVersionId::Version6, + }; // 1. The room create event db.rooms.build_and_append_pdu(