Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
refactor: Use modern URL API in Jitsi call generation.
Dhruv Vira9b18fb4e9f07
diff --git a/web/src/compose_call.ts b/web/src/compose_call.tsindex 2bdf19c35be..c96d233bb07 100644--- a/web/src/compose_call.ts+++ b/web/src/compose_call.ts@@ -3,8 +3,16 @@ import {realm} from "./state_data.ts";export const zoom_token_callbacks = new Map();export const video_call_xhrs = new Map<string, JQuery.jqXHR<unknown>>();-export function get_jitsi_server_url(): string | null {- return realm.realm_jitsi_server_url ?? realm.server_jitsi_server_url;+export function get_jitsi_server_url(video_call_id?: string): URL | null {+ const base_url = realm.realm_jitsi_server_url ?? realm.server_jitsi_server_url;+ if (!base_url) {+ return null;+ }+ const url = new URL(base_url);+ if (video_call_id !== undefined) {+ url.pathname = `/${video_call_id}`;+ }+ return url;}export function abort_video_callbacks(edit_message_id = ""): void {diff --git a/web/src/compose_call_ui.ts b/web/src/compose_call_ui.tsindex 8a9b658a426..bef6bbfe44a 100644--- a/web/src/compose_call_ui.ts+++ b/web/src/compose_call_ui.ts@@ -141,32 +141,32 @@ export function generate_and_insert_audio_or_video_call_link(},});} else {- // TODO: Use `new URL` to generate the URLs here.const video_call_id = util.random_int(100000000000000, 999999999999999);- const video_call_link = compose_call.get_jitsi_server_url() + "/" + video_call_id;+ const video_call_url = compose_call.get_jitsi_server_url(video_call_id.toString());+ if (video_call_url === null) {+ return;+ }+ /* Because Jitsi remembers what last call type you joined+ in browser local storage, we need to specify that video+ should not be muted in the video call case, or your+ next call will also join without video after joining an+ audio-only call.++ This has the annoying downside that it requires users+ who have a personal preference to disable video every+ time, but Jitsi's UI makes that very easy to do, and+ that inconvenience is probably less important than letting+ the person organizing a call specify their intended+ call type (video vs audio).+ */+ const video_muted = is_audio_call ? "true" : "false";+ video_call_url.hash = `config.startWithVideoMuted=${video_muted}`;+ const video_call_link = video_call_url.toString();+if (is_audio_call) {- insert_audio_call_url(- video_call_link + "#config.startWithVideoMuted=true",- $target_textarea,- );+ insert_audio_call_url(video_call_link, $target_textarea);} else {- /* Because Jitsi remembers what last call type you joined- in browser local storage, we need to specify that video- should not be muted in the video call case, or your- next call will also join without video after joining an- audio-only call.-- This has the annoying downside that it requires users- who have a personal preference to disable video every- time, but Jitsi's UI makes that very easy to do, and- that inconvenience is probably less important than letting- the person organizing a call specify their intended- call type (video vs audio).- */- insert_video_call_url(- video_call_link + "#config.startWithVideoMuted=false",- $target_textarea,- );+ insert_video_call_url(video_call_link, $target_textarea);}}}