From 65a0edc3a6fbb52b736a1d21c7c93c68b5732c71 Mon Sep 17 00:00:00 2001 From: Rubin Elezi Date: Wed, 4 May 2022 07:28:30 +0200 Subject: [PATCH] Don't enable e2ee for bridged platform (#476) * Don't enable e2ee for bridged platform * remove comments * Change function name Co-authored-by: Ajay Bura <32841439+ajbura@users.noreply.github.com> --- src/app/organisms/invite-user/InviteUser.jsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/app/organisms/invite-user/InviteUser.jsx b/src/app/organisms/invite-user/InviteUser.jsx index c03d3ad..d0a8d9e 100644 --- a/src/app/organisms/invite-user/InviteUser.jsx +++ b/src/app/organisms/invite-user/InviteUser.jsx @@ -103,6 +103,18 @@ function InviteUser({ updateIsSearching(false); } + async function hasDevices(userId) { + try { + const usersDeviceMap = await mx.downloadKeys([userId, mx.getUserId()]); + return Object.values(usersDeviceMap).every((userDevices) => + Object.keys(userDevices).length > 0, + ); + } catch (e) { + console.error("Error determining if it's possible to encrypt to all users: ", e); + return false; + } + } + async function createDM(userId) { if (mx.getUserId() === userId) return; const dmRoomId = hasDMWith(userId); @@ -117,7 +129,7 @@ function InviteUser({ procUserError.delete(userId); updateUserProcError(getMapCopy(procUserError)); - const result = await roomActions.createDM(userId); + const result = await roomActions.createDM(userId, await hasDevices(userId)); roomIdToUserId.set(result.room_id, userId); updateRoomIdToUserId(getMapCopy(roomIdToUserId)); } catch (e) {