From 780eab83f8db3a113a701bd719938ca26c95984f Mon Sep 17 00:00:00 2001 From: Matthias Ahouansou Date: Fri, 1 Aug 2025 15:52:52 +0200 Subject: [PATCH] feat: MSC4291, Room IDs as hashes of the create event (1/2) (cherry picked from commit f6d14fdabd2a482e926acbeb350c30553e09fde6) --- Cargo.lock | 22 +++++++++++----------- src/api/client_server/room.rs | 13 +++++++------ src/service/admin/mod.rs | 2 +- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e9028ced..345308a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2519,7 +2519,7 @@ dependencies = [ [[package]] name = "ruma" version = "0.12.5" -source = "git+https://github.com/ruma/ruma.git#71069c43650d2a797181aaa2ecc63037eaece907" +source = "git+https://github.com/ruma/ruma.git#739fecf1af28c7348442fc27a66ab34222b99ec3" dependencies = [ "assign", "js_int", @@ -2538,7 +2538,7 @@ dependencies = [ [[package]] name = "ruma-appservice-api" version = "0.12.2" -source = "git+https://github.com/ruma/ruma.git#71069c43650d2a797181aaa2ecc63037eaece907" +source = "git+https://github.com/ruma/ruma.git#739fecf1af28c7348442fc27a66ab34222b99ec3" dependencies = [ "js_int", "ruma-common", @@ -2550,7 +2550,7 @@ dependencies = [ [[package]] name = "ruma-client-api" version = "0.20.4" -source = "git+https://github.com/ruma/ruma.git#71069c43650d2a797181aaa2ecc63037eaece907" +source = "git+https://github.com/ruma/ruma.git#739fecf1af28c7348442fc27a66ab34222b99ec3" dependencies = [ "as_variant", "assign", @@ -2573,7 +2573,7 @@ dependencies = [ [[package]] name = "ruma-common" version = "0.15.4" -source = "git+https://github.com/ruma/ruma.git#71069c43650d2a797181aaa2ecc63037eaece907" +source = "git+https://github.com/ruma/ruma.git#739fecf1af28c7348442fc27a66ab34222b99ec3" dependencies = [ "as_variant", "base64 0.22.1", @@ -2605,7 +2605,7 @@ dependencies = [ [[package]] name = "ruma-events" version = "0.30.4" -source = "git+https://github.com/ruma/ruma.git#71069c43650d2a797181aaa2ecc63037eaece907" +source = "git+https://github.com/ruma/ruma.git#739fecf1af28c7348442fc27a66ab34222b99ec3" dependencies = [ "as_variant", "indexmap 2.9.0", @@ -2629,7 +2629,7 @@ dependencies = [ [[package]] name = "ruma-federation-api" version = "0.11.2" -source = "git+https://github.com/ruma/ruma.git#71069c43650d2a797181aaa2ecc63037eaece907" +source = "git+https://github.com/ruma/ruma.git#739fecf1af28c7348442fc27a66ab34222b99ec3" dependencies = [ "bytes", "headers", @@ -2651,7 +2651,7 @@ dependencies = [ [[package]] name = "ruma-identifiers-validation" version = "0.10.1" -source = "git+https://github.com/ruma/ruma.git#71069c43650d2a797181aaa2ecc63037eaece907" +source = "git+https://github.com/ruma/ruma.git#739fecf1af28c7348442fc27a66ab34222b99ec3" dependencies = [ "js_int", "thiserror 2.0.12", @@ -2660,7 +2660,7 @@ dependencies = [ [[package]] name = "ruma-macros" version = "0.15.2" -source = "git+https://github.com/ruma/ruma.git#71069c43650d2a797181aaa2ecc63037eaece907" +source = "git+https://github.com/ruma/ruma.git#739fecf1af28c7348442fc27a66ab34222b99ec3" dependencies = [ "cfg-if", "proc-macro-crate", @@ -2675,7 +2675,7 @@ dependencies = [ [[package]] name = "ruma-push-gateway-api" version = "0.11.0" -source = "git+https://github.com/ruma/ruma.git#71069c43650d2a797181aaa2ecc63037eaece907" +source = "git+https://github.com/ruma/ruma.git#739fecf1af28c7348442fc27a66ab34222b99ec3" dependencies = [ "js_int", "ruma-common", @@ -2687,7 +2687,7 @@ dependencies = [ [[package]] name = "ruma-signatures" version = "0.17.1" -source = "git+https://github.com/ruma/ruma.git#71069c43650d2a797181aaa2ecc63037eaece907" +source = "git+https://github.com/ruma/ruma.git#739fecf1af28c7348442fc27a66ab34222b99ec3" dependencies = [ "base64 0.22.1", "ed25519-dalek", @@ -2703,7 +2703,7 @@ dependencies = [ [[package]] name = "ruma-state-res" version = "0.13.0" -source = "git+https://github.com/ruma/ruma.git#71069c43650d2a797181aaa2ecc63037eaece907" +source = "git+https://github.com/ruma/ruma.git#739fecf1af28c7348442fc27a66ab34222b99ec3" dependencies = [ "js_int", "ruma-common", diff --git a/src/api/client_server/room.rs b/src/api/client_server/room.rs index c6dcb4c3..558e9d68 100644 --- a/src/api/client_server/room.rs +++ b/src/api/client_server/room.rs @@ -57,7 +57,7 @@ pub async fn create_room_route( let sender_user = body.sender_user.as_ref().expect("user is authenticated"); - let room_id = RoomId::new(services().globals.server_name()); + let room_id = RoomId::new_v1(services().globals.server_name()); services().rooms.short.get_or_create_shortroomid(&room_id)?; @@ -622,7 +622,7 @@ pub async fn upgrade_room_route( .authorization; // Create a replacement room - let replacement_room = RoomId::new(services().globals.server_name()); + let replacement_room = RoomId::new_v1(services().globals.server_name()); services() .rooms .short @@ -689,10 +689,11 @@ pub async fn upgrade_room_route( .map_err(|_| Error::bad_database("Invalid room event in database."))?; // Use the m.room.tombstone event as the predecessor - let predecessor = Some(ruma::events::room::create::PreviousRoom::new( - body.room_id.clone(), - (*tombstone_event_id).to_owned(), - )); + #[allow(deprecated)] + let predecessor = Some(ruma::events::room::create::PreviousRoom { + room_id: body.room_id.clone(), + event_id: Some((*tombstone_event_id).to_owned()), + }); // Send a m.room.create event containing a predecessor field and the applicable room_version if rules.use_room_create_sender { diff --git a/src/service/admin/mod.rs b/src/service/admin/mod.rs index 6255bdac..6199d6e5 100644 --- a/src/service/admin/mod.rs +++ b/src/service/admin/mod.rs @@ -1669,7 +1669,7 @@ impl Service { /// Users in this room are considered admins by conduit, and the room can be /// used to issue admin commands by talking to the server user inside it. pub(crate) async fn create_admin_room(&self) -> Result<()> { - let room_id = RoomId::new(services().globals.server_name()); + let room_id = RoomId::new_v1(services().globals.server_name()); services().rooms.short.get_or_create_shortroomid(&room_id)?;