From d23f7f7e819681e25aac5ffa84897efdf2d8d43e Mon Sep 17 00:00:00 2001 From: dasha_uwu Date: Sun, 22 Feb 2026 12:58:01 +0500 Subject: [PATCH] Fix encryption_enabled_by_default_for_room_type When set to "invite" all rooms were created with encryption --- src/api/client/room/create.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/api/client/room/create.rs b/src/api/client/room/create.rs index a8c87443..087cbf81 100644 --- a/src/api/client/room/create.rs +++ b/src/api/client/room/create.rs @@ -310,12 +310,15 @@ pub(crate) async fn create_room_route( let config = services .config .encryption_enabled_by_default_for_room_type - .as_deref() - .unwrap_or("off"); + .as_deref(); - let invite = matches!(config, "invite"); - let always = matches!(config, "all" | "invite"); - if always || (invite && matches!(preset, PrivateChat | TrustedPrivateChat)) { + let should_encrypt = match config { + | Some("all") => true, + | Some("invite") => matches!(preset, PrivateChat | TrustedPrivateChat), + | _ => false, + }; + + if should_encrypt { let algorithm = EventEncryptionAlgorithm::MegolmV1AesSha2; let content = RoomEncryptionEventContent::new(algorithm); services