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
.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