chore(spaces): cosmetic cleanup from review 5

- Remove redundant StdHashSet import alias in cache_tests.rs
- Add type alias SpaceEnforcementData for readability in build.rs
- Fix formatting of for-loop closing brace in PL check
- Move BTreeMap and RoleDefinition imports to file-level in build.rs

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
ember33 2026-03-18 10:59:49 +01:00
parent 4c0ec5f7a0
commit 50604724ff
3 changed files with 18 additions and 6 deletions

View file

@ -470,6 +470,12 @@
#
#suspend_on_register = false
# Enable space permission cascading (power levels and role-based access).
# When enabled, power levels cascade from Spaces to child rooms and rooms
# can require roles for access. Applies to all Spaces on this server.
#
#space_permission_cascading = false
# Enabling this setting opens registration to anyone without restrictions.
# This makes your server vulnerable to abuse
#

View file

@ -4,7 +4,6 @@ use std::collections::{BTreeMap, HashMap, HashSet};
use conduwuit_core::matrix::space_roles::RoleDefinition;
use ruma::{room_id, user_id, OwnedRoomId, OwnedUserId};
use std::collections::HashSet as StdHashSet;
use super::tests::{make_requirements, make_roles, make_user_roles};
@ -13,7 +12,7 @@ struct MockCache {
roles: HashMap<OwnedRoomId, BTreeMap<String, RoleDefinition>>,
user_roles: HashMap<OwnedRoomId, HashMap<OwnedUserId, HashSet<String>>>,
room_requirements: HashMap<OwnedRoomId, HashMap<OwnedRoomId, HashSet<String>>>,
room_to_space: HashMap<OwnedRoomId, StdHashSet<OwnedRoomId>>,
room_to_space: HashMap<OwnedRoomId, HashSet<OwnedRoomId>>,
}
impl MockCache {

View file

@ -1,4 +1,9 @@
use std::{collections::HashSet, iter::once};
use std::{
collections::{BTreeMap, HashSet},
iter::once,
};
use conduwuit_core::matrix::space_roles::RoleDefinition;
use conduwuit::trace;
use conduwuit_core::{
@ -120,12 +125,14 @@ pub async fn build_and_append_pdu(
}
}
}
}
}
// Also check that space-managed users aren't omitted
// Clone data out of guards to avoid holding locks across await
let space_data: Vec<(ruma::OwnedRoomId, Vec<(OwnedUserId, HashSet<String>)>, std::collections::BTreeMap<String, conduwuit_core::matrix::space_roles::RoleDefinition>)> = {
type SpaceEnforcementData =
(ruma::OwnedRoomId, Vec<(OwnedUserId, HashSet<String>)>, BTreeMap<String, RoleDefinition>);
let space_data: Vec<SpaceEnforcementData> = {
let user_roles_guard = self.services.roles.user_roles.read().await;
let roles_guard = self.services.roles.roles.read().await;
parent_spaces.iter().filter_map(|ps| {