Add e2ee_default_for_private_rooms to control default e2ee behaviour

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2020-05-19 11:36:44 +01:00
parent 1eea203db6
commit 0016d8e744
4 changed files with 12 additions and 7 deletions

View file

@ -24,6 +24,7 @@ import * as Rooms from "./Rooms";
import DMRoomMap from "./utils/DMRoomMap";
import {getAddressType} from "./UserAddress";
import SettingsStore from "./settings/SettingsStore";
import SdkConfig from "./SdkConfig";
/**
* Create a new room, and switch to it.
@ -227,7 +228,7 @@ export async function ensureDMExists(client, userId) {
roomId = existingDMRoom.roomId;
} else {
let encryption;
if (SettingsStore.getValue("feature_cross_signing")) {
if (privateShouldBeEncrypted()) {
encryption = canEncryptToAllUsers(client, [userId]);
}
roomId = await createRoom({encryption, dmUserId: userId, spinner: false, andView: false});
@ -235,3 +236,7 @@ export async function ensureDMExists(client, userId) {
}
return roomId;
}
export function privateShouldBeEncrypted() {
return SettingsStore.getValue("feature_cross_signing") && SdkConfig.get().e2ee_default_for_private_rooms !== false;
}