From fac995036ab02fe30fca6a2dfc682612c4cf43d7 Mon Sep 17 00:00:00 2001 From: Val Lorentz Date: Fri, 1 Dec 2023 18:15:57 +0100 Subject: [PATCH] create_hash_and_sign_event: Use actual version of RoomCreate events, instead of the default --- src/service/rooms/timeline/mod.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/service/rooms/timeline/mod.rs b/src/service/rooms/timeline/mod.rs index 4b06acb7..a6e9f87a 100644 --- a/src/service/rooms/timeline/mod.rs +++ b/src/service/rooms/timeline/mod.rs @@ -695,11 +695,20 @@ impl Service { .take(20) .collect(); - // If there was no create event yet, assume we are creating a room with the default - // version right now - let room_version_id = self - .get_room_version(room_id)? - .unwrap_or_else(|| services().globals.default_room_version()); + // If there was no create event yet, assume we are creating a room + let room_version_id = self.get_room_version(room_id)?.unwrap_or_else(|| { + if event_type != TimelineEventType::RoomCreate { + panic!("non-create event for room of unknown version"); + } + #[derive(Deserialize)] + struct RoomCreate { + room_version: RoomVersionId, + } + let content = serde_json::from_str::(content.get()) + .expect("Invalid content in RoomCreate pdu."); + content.room_version + }); + let room_version = RoomVersion::new(&room_version_id).expect("room version is supported"); let auth_events = services().rooms.state.get_auth_events(