fix(spaces): add early is_enabled() check in join path, use err! macro
Some checks failed
Documentation / Build and Deploy Documentation (pull_request) Has been skipped
Checks / Prek / Pre-commit & Formatting (pull_request) Failing after 4s
Checks / Prek / Clippy and Cargo Tests (pull_request) Failing after 5s
Update flake hashes / update-flake-hashes (pull_request) Failing after 5s

Skip lock acquisition on every join when feature is globally disabled.
Use conduwuit::err! macro instead of manual Error::Err construction.
This commit is contained in:
ember33 2026-03-19 16:47:28 +01:00
parent ce239078c2
commit f5ab4da12d
3 changed files with 7 additions and 7 deletions

View file

@ -51,9 +51,7 @@ macro_rules! custom_state_pdu {
PduBuilder {
event_type: $event_type.to_owned().into(),
content: to_raw_value($content).map_err(|e| {
conduwuit::Error::Err(
format!("Failed to serialize custom state event content: {e}").into(),
)
conduwuit::err!(Err("Failed to serialize state event content: {e}"))
})?,
state_key: Some($state_key.to_owned().into()),
..PduBuilder::default()

View file

@ -347,7 +347,11 @@ pub async fn join_room_by_id_helper(
}
}
let parent_spaces = services.rooms.roles.get_parent_spaces(room_id).await;
let parent_spaces = if services.rooms.roles.is_enabled() {
services.rooms.roles.get_parent_spaces(room_id).await
} else {
Vec::new()
};
if !parent_spaces.is_empty() {
let mut qualifies_in_any = false;
for parent_space in &parent_spaces {

View file

@ -216,9 +216,7 @@ pub async fn ensure_default_roles(&self, space_id: &RoomId) -> Result {
let pdu = PduBuilder {
event_type: ruma::events::TimelineEventType::from(SPACE_ROLES_EVENT_TYPE.to_owned()),
content: to_raw_value(&content).map_err(|e| {
conduwuit::Error::Err(
format!("Failed to serialize SpaceRolesEventContent: {e}").into(),
)
conduwuit::err!(Err("Failed to serialize SpaceRolesEventContent: {e}"))
})?,
state_key: Some(String::new().into()),
..PduBuilder::default()