Fix encryption_enabled_by_default_for_room_type

When set to "invite" all rooms were created with encryption
This commit is contained in:
dasha_uwu
2026-02-22 12:58:01 +05:00
parent 0381547c52
commit d23f7f7e81

View File

@@ -310,12 +310,15 @@ pub(crate) async fn create_room_route(
let config = services let config = services
.config .config
.encryption_enabled_by_default_for_room_type .encryption_enabled_by_default_for_room_type
.as_deref() .as_deref();
.unwrap_or("off");
let invite = matches!(config, "invite"); let should_encrypt = match config {
let always = matches!(config, "all" | "invite"); | Some("all") => true,
if always || (invite && matches!(preset, PrivateChat | TrustedPrivateChat)) { | Some("invite") => matches!(preset, PrivateChat | TrustedPrivateChat),
| _ => false,
};
if should_encrypt {
let algorithm = EventEncryptionAlgorithm::MegolmV1AesSha2; let algorithm = EventEncryptionAlgorithm::MegolmV1AesSha2;
let content = RoomEncryptionEventContent::new(algorithm); let content = RoomEncryptionEventContent::new(algorithm);
services services