From d8a7f7c7ca5e6a93dcb955db8b393eb0a7b10cf2 Mon Sep 17 00:00:00 2001 From: timedout Date: Mon, 25 May 2026 19:40:15 +0100 Subject: [PATCH] perf: Skip updating child/parent spaces in upgrade when sender is not joined --- src/api/client/room/upgrade.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/api/client/room/upgrade.rs b/src/api/client/room/upgrade.rs index 6b7614abf..8ce753aff 100644 --- a/src/api/client/room/upgrade.rs +++ b/src/api/client/room/upgrade.rs @@ -67,6 +67,15 @@ async fn update_parents( for raw_parent_id in parents { let parent_id = RoomId::parse(&raw_parent_id)?; + if !services + .rooms + .state_cache + .is_joined(sender, &parent_id) + .await + { + debug!(%parent_id, "Skipping space as sender is not joined"); + continue; // Skip updating rooms the sender isn't in. + } let state_lock = services.rooms.state.mutex.lock(parent_id.as_str()).await; // We're now fetching state from the *space* that has the old room as a *child*. // Follow along. This will be on the test. @@ -159,6 +168,15 @@ async fn update_children( for raw_child_id in parents { let child_id = RoomId::parse(&raw_child_id)?; + if !services + .rooms + .state_cache + .is_joined(sender, &child_id) + .await + { + debug!(%child_id, "Skipping child room as sender is not joined"); + continue; + } let state_lock = services.rooms.state.mutex.lock(child_id.as_str()).await; // We're now fetching state from the *child* that has the old space as a // *parent*. Follow along. This will also be on the test.