create_hash_and_sign_event: Use actual version of RoomCreate events, instead of the default

This commit is contained in:
Val Lorentz 2023-12-01 18:15:57 +01:00
parent 18bfd79ef2
commit fac995036a

View file

@ -695,11 +695,20 @@ impl Service {
.take(20) .take(20)
.collect(); .collect();
// If there was no create event yet, assume we are creating a room with the default // If there was no create event yet, assume we are creating a room
// version right now let room_version_id = self.get_room_version(room_id)?.unwrap_or_else(|| {
let room_version_id = self if event_type != TimelineEventType::RoomCreate {
.get_room_version(room_id)? panic!("non-create event for room of unknown version");
.unwrap_or_else(|| services().globals.default_room_version()); }
#[derive(Deserialize)]
struct RoomCreate {
room_version: RoomVersionId,
}
let content = serde_json::from_str::<RoomCreate>(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 room_version = RoomVersion::new(&room_version_id).expect("room version is supported");
let auth_events = services().rooms.state.get_auth_events( let auth_events = services().rooms.state.get_auth_events(