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

@ -25,6 +25,7 @@ import { _t } from '../../../languageHandler';
import {MatrixClientPeg} from '../../../MatrixClientPeg'; import {MatrixClientPeg} from '../../../MatrixClientPeg';
import {Key} from "../../../Keyboard"; import {Key} from "../../../Keyboard";
import SettingsStore from "../../../settings/SettingsStore"; import SettingsStore from "../../../settings/SettingsStore";
import {privateShouldBeEncrypted} from "../../../createRoom";
export default createReactClass({ export default createReactClass({
displayName: 'CreateRoomDialog', displayName: 'CreateRoomDialog',
@ -37,7 +38,7 @@ export default createReactClass({
const config = SdkConfig.get(); const config = SdkConfig.get();
return { return {
isPublic: this.props.defaultPublic || false, isPublic: this.props.defaultPublic || false,
isEncrypted: true, isEncrypted: privateShouldBeEncrypted(),
name: "", name: "",
topic: "", topic: "",
alias: "", alias: "",

View file

@ -31,9 +31,8 @@ import dis from "../../../dispatcher";
import IdentityAuthClient from "../../../IdentityAuthClient"; import IdentityAuthClient from "../../../IdentityAuthClient";
import Modal from "../../../Modal"; import Modal from "../../../Modal";
import {humanizeTime} from "../../../utils/humanize"; import {humanizeTime} from "../../../utils/humanize";
import createRoom, {canEncryptToAllUsers} from "../../../createRoom"; import createRoom, {canEncryptToAllUsers, privateShouldBeEncrypted} from "../../../createRoom";
import {inviteMultipleToRoom} from "../../../RoomInvite"; import {inviteMultipleToRoom} from "../../../RoomInvite";
import SettingsStore from '../../../settings/SettingsStore';
import RoomListStore, {TAG_DM} from "../../../stores/RoomListStore"; import RoomListStore, {TAG_DM} from "../../../stores/RoomListStore";
import {Key} from "../../../Keyboard"; import {Key} from "../../../Keyboard";
@ -574,7 +573,7 @@ export default class InviteDialog extends React.PureComponent {
const createRoomOptions = {inlineErrors: true}; const createRoomOptions = {inlineErrors: true};
if (SettingsStore.getValue("feature_cross_signing")) { if (privateShouldBeEncrypted()) {
// Check whether all users have uploaded device keys before. // Check whether all users have uploaded device keys before.
// If so, enable encryption in the new room. // If so, enable encryption in the new room.
const has3PidMembers = targets.some(t => t instanceof ThreepidMember); const has3PidMembers = targets.some(t => t instanceof ThreepidMember);

View file

@ -25,7 +25,7 @@ import dis from '../../../dispatcher';
import Modal from '../../../Modal'; import Modal from '../../../Modal';
import * as sdk from '../../../index'; import * as sdk from '../../../index';
import { _t } from '../../../languageHandler'; import { _t } from '../../../languageHandler';
import createRoom from '../../../createRoom'; import createRoom, {privateShouldBeEncrypted} from '../../../createRoom';
import DMRoomMap from '../../../utils/DMRoomMap'; import DMRoomMap from '../../../utils/DMRoomMap';
import AccessibleButton from '../elements/AccessibleButton'; import AccessibleButton from '../elements/AccessibleButton';
import SdkConfig from '../../../SdkConfig'; import SdkConfig from '../../../SdkConfig';
@ -111,7 +111,7 @@ async function openDMForUser(matrixClient, userId) {
dmUserId: userId, dmUserId: userId,
}; };
if (SettingsStore.getValue("feature_cross_signing")) { if (privateShouldBeEncrypted()) {
// Check whether all users have uploaded device keys before. // Check whether all users have uploaded device keys before.
// If so, enable encryption in the new room. // If so, enable encryption in the new room.
const usersToDevicesMap = await matrixClient.downloadKeys([userId]); const usersToDevicesMap = await matrixClient.downloadKeys([userId]);

View file

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