Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
add tests and make url flags explicit
Browse files Browse the repository at this point in the history
Signed-off-by: Timo K <[email protected]>
  • Loading branch information
toger5 committed Nov 10, 2023
1 parent 4ccd536 commit 2fce39c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/models/Call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down
24 changes: 24 additions & 0 deletions test/models/Call-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down

0 comments on commit 2fce39c

Please sign in to comment.