From 62f41f0961ce55f5b1785435a79cd085a403e25e Mon Sep 17 00:00:00 2001 From: Timo <16718859+toger5@users.noreply.github.com> Date: Fri, 10 Nov 2023 17:46:02 +0100 Subject: [PATCH] Add feature flag for disabling encryption in Element Call (#11837) * add feature flag for disabling encryption Signed-off-by: Timo K * prettier Signed-off-by: Timo K * Update src/i18n/strings/en_EN.json Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> * add tests and make url flags explicit Signed-off-by: Timo K * remove unnecessary braces Signed-off-by: Timo K --------- Signed-off-by: Timo K Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> --- src/i18n/strings/en_EN.json | 1 + src/models/Call.ts | 8 +++++--- src/settings/Settings.tsx | 7 +++++++ test/models/Call-test.ts | 24 ++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 7ae2f7a70f..d5b76383b4 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 ecf1cbab66..9a841eb9d7 100644 --- a/src/models/Call.ts +++ b/src/models/Call.ts @@ -661,9 +661,11 @@ export class ElementCall extends Call { analyticsID, }); - if (client.isRoomEncrypted(roomId)) params.append("perParticipantE2EE", ""); - if (SettingsStore.getValue("fallbackICEServerAllowed")) params.append("allowIceFallback", ""); - if (SettingsStore.getValue("feature_allow_screen_share_only_mode")) params.append("allowVoipWithNoMedia", ""); + if (client.isRoomEncrypted(roomId) && !SettingsStore.getValue("feature_disable_call_per_sender_encryption")) + 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/src/settings/Settings.tsx b/src/settings/Settings.tsx index 7f92f0413f..4f000f300c 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, diff --git a/test/models/Call-test.ts b/test/models/Call-test.ts index bd394e628b..cbf1df0ffa 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", () => {