From 4e98b5b4b60e150f4ed594b280a3fd733803ee40 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 28 Apr 2020 17:41:10 +0200 Subject: [PATCH 1/3] dont enable e2ee when inviting a 3pid --- src/components/views/dialogs/InviteDialog.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/components/views/dialogs/InviteDialog.js b/src/components/views/dialogs/InviteDialog.js index a46fa0df07..a2a0eddd8e 100644 --- a/src/components/views/dialogs/InviteDialog.js +++ b/src/components/views/dialogs/InviteDialog.js @@ -577,10 +577,13 @@ export default class InviteDialog extends React.PureComponent { if (SettingsStore.getValue("feature_cross_signing")) { // Check whether all users have uploaded device keys before. // If so, enable encryption in the new room. - const client = MatrixClientPeg.get(); - const allHaveDeviceKeys = await canEncryptToAllUsers(client, targetIds); - if (allHaveDeviceKeys) { - createRoomOptions.encryption = true; + const containsNonMatrixUsers = targets.some(t => !(t instanceof DirectoryMember)); + if (!containsNonMatrixUsers) { + const client = MatrixClientPeg.get(); + const allHaveDeviceKeys = await canEncryptToAllUsers(client, targetIds); + if (allHaveDeviceKeys) { + createRoomOptions.encryption = true; + } } } From f06a69d8ccaac280c834baf02166154777588e18 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 28 Apr 2020 18:38:54 +0200 Subject: [PATCH 2/3] targets can also contain RoomMember, so take the positive case rather --- src/components/views/dialogs/InviteDialog.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/views/dialogs/InviteDialog.js b/src/components/views/dialogs/InviteDialog.js index a2a0eddd8e..759228babd 100644 --- a/src/components/views/dialogs/InviteDialog.js +++ b/src/components/views/dialogs/InviteDialog.js @@ -577,8 +577,8 @@ export default class InviteDialog extends React.PureComponent { if (SettingsStore.getValue("feature_cross_signing")) { // Check whether all users have uploaded device keys before. // If so, enable encryption in the new room. - const containsNonMatrixUsers = targets.some(t => !(t instanceof DirectoryMember)); - if (!containsNonMatrixUsers) { + const has3PidMembers = targets.some(t => t instanceof ThreepidMember); + if (has3PidMembers) { const client = MatrixClientPeg.get(); const allHaveDeviceKeys = await canEncryptToAllUsers(client, targetIds); if (allHaveDeviceKeys) { From bb6d13781c47585c0ca3159fc95f8c1487a2d845 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Wed, 29 Apr 2020 11:40:04 +0200 Subject: [PATCH 3/3] enable encryption when NOT inviting 3pids --- src/components/views/dialogs/InviteDialog.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/dialogs/InviteDialog.js b/src/components/views/dialogs/InviteDialog.js index 759228babd..e48c6866bf 100644 --- a/src/components/views/dialogs/InviteDialog.js +++ b/src/components/views/dialogs/InviteDialog.js @@ -578,7 +578,7 @@ export default class InviteDialog extends React.PureComponent { // Check whether all users have uploaded device keys before. // If so, enable encryption in the new room. const has3PidMembers = targets.some(t => t instanceof ThreepidMember); - if (has3PidMembers) { + if (!has3PidMembers) { const client = MatrixClientPeg.get(); const allHaveDeviceKeys = await canEncryptToAllUsers(client, targetIds); if (allHaveDeviceKeys) {