Improve space (and room!) upgrades #907

Merged
nex merged 8 commits from nex/feat/space-upgrades into main 2025-07-19 18:44:56 +00:00
Owner

This PR does the following:

  • Implements MSC4168 by updating both the parent and child space references
  • Fixes an issue where only state with an empty state key ("") is cloned
  • Adds a helper function that allows the state_accessor service to iterate over all of the state keys for a given event type

This is primarily in preparation for room v12, where some people may desire to upgrade their spaces.
It is important to note that some clients, such as Element Web and possibly Cinny, perform these new steps client-side as well. Given we create & send the events first, this just results in overlapping behaviour, rather than a functional issue, and is safe to ignore.

This PR does the following: - Implements [MSC4168](https://github.com/matrix-org/matrix-spec-proposals/pull/4168) by updating both the parent and child space references - Fixes an issue where only state with an empty state key (`""`) is cloned - Adds a helper function that allows the `state_accessor` service to iterate over all of the state keys for a given event type This is primarily in preparation for room v12, where some people may desire to upgrade their spaces. It is important to note that some clients, such as Element Web and possibly Cinny, perform these new steps client-side as well. Given we create & send the events first, this just results in overlapping behaviour, rather than a functional issue, and is safe to ignore.
nex added this to the 0.5.0 milestone 2025-07-19 14:47:46 +00:00
nex added the
Enhancement
Matrix/Client
Matrix/MSC
labels 2025-07-19 14:47:46 +00:00
nex added 7 commits 2025-07-19 14:47:46 +00:00
feat(space-upgrades): Copy over space child & parent states
All checks were successful
Release Docker Image / define-variables (push) Successful in 2s
Checks / Prefligit / prefligit (push) Successful in 28s
Checks / Rust / Format (push) Successful in 59s
Checks / Rust / Clippy (push) Successful in 4m5s
Checks / Rust / Cargo Test (push) Successful in 4m36s
Release Docker Image / build-image (linux/amd64, release, linux-amd64, base) (push) Successful in 10m54s
Release Docker Image / build-image (linux/arm64, release, linux-arm64, base) (push) Successful in 21m28s
Release Docker Image / merge (push) Successful in 31s
f7410283cf
This relies on the room being upgraded referencing
the space itself, but there isn't an easy way to
do it otherwise.
Before this change, only state events with an
empty state key would be cloned.
This allows m.space.child to be cloned appropriately.
fix(space-upgrades): Incorrectly updated parent children events
Some checks failed
Release Docker Image / merge (push) Blocked by required conditions
Release Docker Image / define-variables (push) Successful in 2s
Checks / Prefligit / prefligit (push) Successful in 26s
Checks / Rust / Format (push) Successful in 44s
Checks / Rust / Clippy (push) Successful in 3m41s
Checks / Rust / Cargo Test (push) Successful in 4m10s
Release Docker Image / build-image (linux/amd64, release, linux-amd64, base) (push) Has been cancelled
Release Docker Image / build-image (linux/arm64, release, linux-arm64, base) (push) Has been cancelled
390c1ab18e
feat(space-upgrades): Skip empty state events in room upgrade
Some checks failed
Release Docker Image / build-image (linux/arm64, release, linux-arm64, base) (push) Blocked by required conditions
Release Docker Image / merge (push) Blocked by required conditions
Release Docker Image / define-variables (push) Successful in 3s
Checks / Prefligit / prefligit (push) Successful in 27s
Checks / Rust / Format (push) Successful in 41s
Checks / Rust / Cargo Test (push) Has been cancelled
Checks / Rust / Clippy (push) Has been cancelled
Release Docker Image / build-image (linux/amd64, release, linux-amd64, base) (push) Has been cancelled
e586dcd8f2
fix(space-upgrades): Remove unused helper function
Some checks failed
Release Docker Image / build-image (linux/amd64, release, linux-amd64, base) (push) Blocked by required conditions
Release Docker Image / merge (push) Blocked by required conditions
Checks / Rust / Clippy (push) Waiting to run
Checks / Rust / Cargo Test (push) Waiting to run
Release Docker Image / define-variables (push) Successful in 4s
Checks / Prefligit / prefligit (push) Successful in 21s
Checks / Rust / Format (push) Successful in 45s
Checks / Prefligit / prefligit (pull_request) Successful in 23s
Documentation / Build and Deploy Documentation (pull_request) Successful in 49s
Release Docker Image / build-image (linux/arm64, release, linux-arm64, base) (push) Has been cancelled
b75842ab88
requested reviews from Jade, Owners 2025-07-19 14:47:53 +00:00
nex added 1 commit 2025-07-19 14:51:09 +00:00
feat(space-upgrades): MSC4168: Override space child vias
Some checks failed
Release Docker Image / build-image (linux/arm64, release, linux-arm64, base) (push) Blocked by required conditions
Release Docker Image / merge (push) Blocked by required conditions
Release Docker Image / define-variables (push) Successful in 2s
Checks / Prefligit / prefligit (push) Successful in 35s
Checks / Rust / Format (push) Successful in 53s
Documentation / Build and Deploy Documentation (pull_request) Successful in 49s
Checks / Prefligit / prefligit (pull_request) Successful in 27s
Checks / Rust / Clippy (push) Failing after 3m40s
Release Docker Image / build-image (linux/amd64, release, linux-amd64, base) (push) Has been cancelled
Checks / Rust / Cargo Test (push) Failing after 16m35s
6691b7672b
nex added 1 commit 2025-07-19 14:57:58 +00:00
style(space-upgrades): Remove unused import left over from 6691b7672b
All checks were successful
Release Docker Image / define-variables (push) Successful in 17s
Checks / Prefligit / prefligit (push) Successful in 53s
Checks / Rust / Format (push) Successful in 1m4s
Documentation / Build and Deploy Documentation (pull_request) Successful in 36s
Checks / Prefligit / prefligit (pull_request) Successful in 19s
Checks / Rust / Clippy (push) Successful in 5m22s
Checks / Rust / Cargo Test (push) Successful in 5m46s
Release Docker Image / build-image (linux/amd64, release, linux-amd64, base) (push) Successful in 13m47s
Release Docker Image / build-image (linux/arm64, release, linux-arm64, base) (push) Successful in 14m4s
Release Docker Image / merge (push) Successful in 27s
607caddacf
Jade force-pushed nex/feat/space-upgrades from 607caddacf to c639228f4d 2025-07-19 17:37:54 +00:00 Compare
Jade approved these changes 2025-07-19 18:14:46 +00:00
Jade left a comment
Owner

I think it's pretty much good, although I wonder if in future it's worth breaking this out into a separate function outside of the API crate.

I think it's pretty much good, although I wonder if in future it's worth breaking this out into a separate function outside of the API crate.
@ -297,0 +338,4 @@
&body.room_id
);
// First, drop the space's child event
let state_lock = services.rooms.state.mutex.lock(space_id).await;
Owner

This lock should probably be an explicit scope. conduwuit::utils::with_lock::WithLock then mutex.with_lock(|state_lock| {, instead of using drop - from the code style guide.

This lock should probably be an explicit scope. `conduwuit::utils::with_lock::WithLock` then `mutex.with_lock(|state_lock| {`, instead of using drop - from the code style guide.
Author
Owner

(resolved with no changes because the desired system isn't compatible with the mutex in question)

(resolved with no changes because the desired system isn't compatible with the mutex in question)
nex marked this conversation as resolved
@ -297,0 +367,4 @@
PduBuilder {
event_type: StateEventType::SpaceChild.into(),
content: to_raw_value(&SpaceChildEventContent {
via: vec![sender_user.server_name().to_owned()],
Owner

Shouldn't via be multiple servers? Although IG we would be the only server in the room, so not much we can do other than update later.

Shouldn't via be multiple servers? Although IG we would be the only server in the room, so not much we can do other than update later.
Author
Owner

MSC explicitly states only the sender server should be included

MSC explicitly states only the sender server should be included
Jade marked this conversation as resolved
nex merged commit c639228f4d into main 2025-07-19 18:44:56 +00:00
nex deleted branch nex/feat/space-upgrades 2025-07-19 18:44:56 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: continuwuation/continuwuity#907
No description provided.