Move E2EE well-known access to utils

This commit is contained in:
J. Ryan Stinnett 2020-08-14 13:27:12 +01:00
parent b293ef0674
commit 2b0865e89c
2 changed files with 40 additions and 12 deletions

View file

@ -26,9 +26,7 @@ import dis from "./dispatcher/dispatcher";
import * as Rooms from "./Rooms";
import DMRoomMap from "./utils/DMRoomMap";
import {getAddressType} from "./UserAddress";
const E2EE_WK_KEY = "im.vector.e2ee";
const E2EE_WK_KEY_DEPRECATED = "im.vector.riot.e2ee";
import { getE2EEWellKnown } from "./utils/WellKnownUtils";
// we define a number of interfaces which take their names from the js-sdk
/* eslint-disable camelcase */
@ -295,16 +293,11 @@ export async function ensureDMExists(client: MatrixClient, userId: string): Prom
return roomId;
}
export function privateShouldBeEncrypted() {
const clientWellKnown = MatrixClientPeg.get().getClientWellKnown();
if (clientWellKnown && clientWellKnown[E2EE_WK_KEY]) {
const defaultDisabled = clientWellKnown[E2EE_WK_KEY]["default"] === false;
export function privateShouldBeEncrypted(): boolean {
const e2eeWellKnown = getE2EEWellKnown();
if (e2eeWellKnown) {
const defaultDisabled = e2eeWellKnown["default"] === false;
return !defaultDisabled;
}
if (clientWellKnown && clientWellKnown[E2EE_WK_KEY_DEPRECATED]) {
const defaultDisabled = clientWellKnown[E2EE_WK_KEY_DEPRECATED]["default"] === false;
return !defaultDisabled;
}
return true;
}