From ac2c9cef8db8bb30a2d0861151923a5caaa485c7 Mon Sep 17 00:00:00 2001 From: Robin Date: Wed, 7 Jun 2023 09:29:39 -0400 Subject: [PATCH] Make group calls respect the ICE fallback setting (#11047) --- src/models/Call.ts | 2 ++ test/models/Call-test.ts | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/models/Call.ts b/src/models/Call.ts index e77612d664..f4123f826a 100644 --- a/src/models/Call.ts +++ b/src/models/Call.ts @@ -659,6 +659,8 @@ export class ElementCall extends Call { analyticsID, }); + if (SettingsStore.getValue("fallbackICEServerAllowed")) params.append("allowIceFallback", ""); + // Set custom fonts if (SettingsStore.getValue("useSystemFont")) { SettingsStore.getValue("systemFont") diff --git a/test/models/Call-test.ts b/test/models/Call-test.ts index 73c62f7137..007b2792a4 100644 --- a/test/models/Call-test.ts +++ b/test/models/Call-test.ts @@ -625,6 +625,36 @@ describe("ElementCall", () => { SettingsStore.getValue = originalGetValue; }); + it("passes ICE fallback preference through widget URL", async () => { + // Test with the preference set to false + await ElementCall.create(room); + const call1 = Call.get(room); + if (!(call1 instanceof ElementCall)) throw new Error("Failed to create call"); + + const urlParams1 = new URLSearchParams(new URL(call1.widget.url).hash.slice(1)); + expect(urlParams1.has("allowIceFallback")).toBe(false); + + // Now test with the preference set to true + const originalGetValue = SettingsStore.getValue; + SettingsStore.getValue = (name: string, roomId?: string, excludeDefault?: boolean) => { + switch (name) { + case "fallbackICEServerAllowed": + return true as T; + default: + return originalGetValue(name, roomId, excludeDefault); + } + }; + + await ElementCall.create(room); + const call2 = Call.get(room); + if (!(call2 instanceof ElementCall)) throw new Error("Failed to create call"); + + const urlParams2 = new URLSearchParams(new URL(call2.widget.url).hash.slice(1)); + expect(urlParams2.has("allowIceFallback")).toBe(true); + + SettingsStore.getValue = originalGetValue; + }); + it("passes analyticsID through widget URL", async () => { client.getAccountData.mockImplementation((eventType: string) => { if (eventType === PosthogAnalytics.ANALYTICS_EVENT_TYPE) {