From cb50c475e53bfb943142fe603864c97c6f6bb6f9 Mon Sep 17 00:00:00 2001 From: Timo K Date: Wed, 8 Nov 2023 16:32:33 +0100 Subject: [PATCH 1/5] add feature flag for disabling encryption Signed-off-by: Timo K --- src/i18n/strings/en_EN.json | 1 + src/models/Call.ts | 2 +- src/settings/Settings.tsx | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 7ae2f7a70f2..fb5830cc3f4 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -1398,6 +1398,7 @@ "element_call_video_rooms": "Element Call video rooms", "experimental_description": "Feeling experimental? Try out our latest ideas in development. These features are not finalised; they may be unstable, may change, or may be dropped altogether. Learn more.", "experimental_section": "Early previews", + "feature_disable_call_per_sender_encryption": "Disable per sender encryption for element call", "feature_wysiwyg_composer_description": "Use rich text instead of Markdown in the message composer.", "group_calls": "New group call experience", "group_developer": "Developer", diff --git a/src/models/Call.ts b/src/models/Call.ts index ecf1cbab665..0ed11e33f54 100644 --- a/src/models/Call.ts +++ b/src/models/Call.ts @@ -661,7 +661,7 @@ export class ElementCall extends Call { analyticsID, }); - if (client.isRoomEncrypted(roomId)) params.append("perParticipantE2EE", ""); + if (client.isRoomEncrypted(roomId) && !SettingsStore.getValue("feature_disable_call_per_sender_encryption")) params.append("perParticipantE2EE", ""); if (SettingsStore.getValue("fallbackICEServerAllowed")) params.append("allowIceFallback", ""); if (SettingsStore.getValue("feature_allow_screen_share_only_mode")) params.append("allowVoipWithNoMedia", ""); diff --git a/src/settings/Settings.tsx b/src/settings/Settings.tsx index 7f92f0413fc..4f000f300c5 100644 --- a/src/settings/Settings.tsx +++ b/src/settings/Settings.tsx @@ -404,6 +404,13 @@ export const SETTINGS: { [setting: string]: ISetting } = { controller: new ReloadOnChangeController(), default: false, }, + "feature_disable_call_per_sender_encryption": { + isFeature: true, + supportedLevels: LEVELS_FEATURE, + labsGroup: LabGroup.VoiceAndVideo, + displayName: _td("labs|feature_disable_call_per_sender_encryption"), + default: false, + }, "feature_allow_screen_share_only_mode": { isFeature: true, supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS_WITH_CONFIG, From 64833e4b3ee4e5477d36b0599ef133574179d007 Mon Sep 17 00:00:00 2001 From: Timo K Date: Wed, 8 Nov 2023 18:05:57 +0100 Subject: [PATCH 2/5] prettier Signed-off-by: Timo K --- src/models/Call.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/models/Call.ts b/src/models/Call.ts index 0ed11e33f54..5b9111d1456 100644 --- a/src/models/Call.ts +++ b/src/models/Call.ts @@ -661,7 +661,8 @@ export class ElementCall extends Call { analyticsID, }); - if (client.isRoomEncrypted(roomId) && !SettingsStore.getValue("feature_disable_call_per_sender_encryption")) params.append("perParticipantE2EE", ""); + if (client.isRoomEncrypted(roomId) && !SettingsStore.getValue("feature_disable_call_per_sender_encryption")) + params.append("perParticipantE2EE", ""); if (SettingsStore.getValue("fallbackICEServerAllowed")) params.append("allowIceFallback", ""); if (SettingsStore.getValue("feature_allow_screen_share_only_mode")) params.append("allowVoipWithNoMedia", ""); From 4ccd5368d24bc86a62ef0aabd5d94bae72d6137f Mon Sep 17 00:00:00 2001 From: Timo <16718859+toger5@users.noreply.github.com> Date: Fri, 10 Nov 2023 13:14:09 +0100 Subject: [PATCH 3/5] Update src/i18n/strings/en_EN.json Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> --- src/i18n/strings/en_EN.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index fb5830cc3f4..d5b76383b47 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -1398,7 +1398,7 @@ "element_call_video_rooms": "Element Call video rooms", "experimental_description": "Feeling experimental? Try out our latest ideas in development. These features are not finalised; they may be unstable, may change, or may be dropped altogether. Learn more.", "experimental_section": "Early previews", - "feature_disable_call_per_sender_encryption": "Disable per sender encryption for element call", + "feature_disable_call_per_sender_encryption": "Disable per-sender encryption for Element Call", "feature_wysiwyg_composer_description": "Use rich text instead of Markdown in the message composer.", "group_calls": "New group call experience", "group_developer": "Developer", From 2fce39cf407ab90c1960016f89accd2a7dd70b42 Mon Sep 17 00:00:00 2001 From: Timo K Date: Fri, 10 Nov 2023 15:40:57 +0100 Subject: [PATCH 4/5] add tests and make url flags explicit Signed-off-by: Timo K --- src/models/Call.ts | 7 ++++--- test/models/Call-test.ts | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/models/Call.ts b/src/models/Call.ts index 5b9111d1456..9a841eb9d75 100644 --- a/src/models/Call.ts +++ b/src/models/Call.ts @@ -662,9 +662,10 @@ export class ElementCall extends Call { }); if (client.isRoomEncrypted(roomId) && !SettingsStore.getValue("feature_disable_call_per_sender_encryption")) - params.append("perParticipantE2EE", ""); - if (SettingsStore.getValue("fallbackICEServerAllowed")) params.append("allowIceFallback", ""); - if (SettingsStore.getValue("feature_allow_screen_share_only_mode")) params.append("allowVoipWithNoMedia", ""); + params.append("perParticipantE2EE", "true"); + if (SettingsStore.getValue("fallbackICEServerAllowed")) params.append("allowIceFallback", "true"); + if (SettingsStore.getValue("feature_allow_screen_share_only_mode")) + params.append("allowVoipWithNoMedia", "true"); // Set custom fonts if (SettingsStore.getValue("useSystemFont")) { diff --git a/test/models/Call-test.ts b/test/models/Call-test.ts index bd394e628bb..0a3cb9cf568 100644 --- a/test/models/Call-test.ts +++ b/test/models/Call-test.ts @@ -925,6 +925,30 @@ describe("ElementCall", () => { call.destroy(); expect(destroyPersistentWidgetSpy).toHaveBeenCalled(); }); + + it("the perParticipantE2EE url flag is used in encrypted rooms while respecting the feature_disable_call_per_sender_encryption flag", async () => { + // We destroy the call created in beforeEach because we test the call creation process. + call.destroy(); + const addWidgetSpy = jest.spyOn(WidgetStore.instance, "addVirtualWidget"); + // If a room is not encrypted we will never add the perParticipantE2EE flag. + client.isRoomEncrypted.mockReturnValue(true); + { + // should create call with perParticipantE2EE flag + ElementCall.create(room); + + expect(addWidgetSpy.mock.calls[0][0].url).toContain("perParticipantE2EE=true"); + ElementCall.get(room)?.destroy(); + + // should create call without perParticipantE2EE flag + enabledSettings.add("feature_disable_call_per_sender_encryption"); + await ElementCall.create(room); + enabledSettings.delete("feature_disable_call_per_sender_encryption"); + + expect(addWidgetSpy.mock.calls[1][0].url).not.toContain("perParticipantE2EE=true"); + } + client.isRoomEncrypted.mockClear(); + addWidgetSpy.mockRestore(); + }); }); describe("instance in a video room", () => { From d4f5dfb0b6ffcced3182cf9906a6412e922568eb Mon Sep 17 00:00:00 2001 From: Timo K Date: Fri, 10 Nov 2023 16:25:45 +0100 Subject: [PATCH 5/5] remove unnecessary braces Signed-off-by: Timo K --- test/models/Call-test.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/test/models/Call-test.ts b/test/models/Call-test.ts index 0a3cb9cf568..cbf1df0ffa4 100644 --- a/test/models/Call-test.ts +++ b/test/models/Call-test.ts @@ -932,20 +932,20 @@ describe("ElementCall", () => { const addWidgetSpy = jest.spyOn(WidgetStore.instance, "addVirtualWidget"); // If a room is not encrypted we will never add the perParticipantE2EE flag. client.isRoomEncrypted.mockReturnValue(true); - { - // should create call with perParticipantE2EE flag - ElementCall.create(room); - expect(addWidgetSpy.mock.calls[0][0].url).toContain("perParticipantE2EE=true"); - ElementCall.get(room)?.destroy(); + // should create call with perParticipantE2EE flag + ElementCall.create(room); + + expect(addWidgetSpy.mock.calls[0][0].url).toContain("perParticipantE2EE=true"); + ElementCall.get(room)?.destroy(); + + // should create call without perParticipantE2EE flag + enabledSettings.add("feature_disable_call_per_sender_encryption"); + await ElementCall.create(room); + enabledSettings.delete("feature_disable_call_per_sender_encryption"); - // should create call without perParticipantE2EE flag - enabledSettings.add("feature_disable_call_per_sender_encryption"); - await ElementCall.create(room); - enabledSettings.delete("feature_disable_call_per_sender_encryption"); + expect(addWidgetSpy.mock.calls[1][0].url).not.toContain("perParticipantE2EE=true"); - expect(addWidgetSpy.mock.calls[1][0].url).not.toContain("perParticipantE2EE=true"); - } client.isRoomEncrypted.mockClear(); addWidgetSpy.mockRestore(); });