mirror of
https://github.com/vector-im/element-call.git
synced 2026-01-18 02:32:27 +00:00
review: Use is_widget directly instead of using the packageType
This commit is contained in:
@@ -15,6 +15,5 @@
|
|||||||
"delayed_leave_event_delay_ms": 18000,
|
"delayed_leave_event_delay_ms": 18000,
|
||||||
"delayed_leave_event_restart_ms": 4000,
|
"delayed_leave_event_restart_ms": 4000,
|
||||||
"network_error_retry_ms": 100
|
"network_error_retry_ms": 100
|
||||||
},
|
}
|
||||||
"trust_localhost_for_mute_state": true
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -165,9 +165,6 @@ export interface ResolvedConfigOptions extends ConfigOptions {
|
|||||||
};
|
};
|
||||||
ssla: string;
|
ssla: string;
|
||||||
app_prompt: boolean;
|
app_prompt: boolean;
|
||||||
// For privacy reasons when lobby is skipped we do not unmute by default on full builds
|
|
||||||
// but for development builds we want to unmute by default to speed up testing.
|
|
||||||
trust_localhost_for_mute_state: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DEFAULT_CONFIG: ResolvedConfigOptions = {
|
export const DEFAULT_CONFIG: ResolvedConfigOptions = {
|
||||||
@@ -182,5 +179,4 @@ export const DEFAULT_CONFIG: ResolvedConfigOptions = {
|
|||||||
},
|
},
|
||||||
ssla: "https://static.element.io/legal/element-software-and-services-license-agreement-uk-1.pdf",
|
ssla: "https://static.element.io/legal/element-software-and-services-license-agreement-uk-1.pdf",
|
||||||
app_prompt: true,
|
app_prompt: true,
|
||||||
trust_localhost_for_mute_state: false,
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -79,9 +79,7 @@ export const RoomPage: FC = () => {
|
|||||||
calculateInitialMuteState(
|
calculateInitialMuteState(
|
||||||
urlParams.skipLobby,
|
urlParams.skipLobby,
|
||||||
urlParams.callIntent,
|
urlParams.callIntent,
|
||||||
import.meta.env.VITE_PACKAGE,
|
widget !== null,
|
||||||
window.location.hostname,
|
|
||||||
Config.get().trust_localhost_for_mute_state,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -12,21 +12,21 @@ import { calculateInitialMuteState } from "./initialMuteState";
|
|||||||
|
|
||||||
test.each<{
|
test.each<{
|
||||||
callIntent: RTCCallIntent;
|
callIntent: RTCCallIntent;
|
||||||
packageType: "full" | "embedded";
|
isWidgetMode: boolean;
|
||||||
}>([
|
}>([
|
||||||
{ callIntent: "audio", packageType: "full" },
|
{ callIntent: "audio", isWidgetMode: false },
|
||||||
{ callIntent: "audio", packageType: "embedded" },
|
{ callIntent: "audio", isWidgetMode: true },
|
||||||
{ callIntent: "video", packageType: "full" },
|
{ callIntent: "video", isWidgetMode: false },
|
||||||
{ callIntent: "video", packageType: "embedded" },
|
{ callIntent: "video", isWidgetMode: true },
|
||||||
{ callIntent: "unknown", packageType: "full" },
|
{ callIntent: "unknown", isWidgetMode: false },
|
||||||
{ callIntent: "unknown", packageType: "embedded" },
|
{ callIntent: "unknown", isWidgetMode: true },
|
||||||
])(
|
])(
|
||||||
"Should allow to unmute on start if not skipping lobby (callIntent: $callIntent, packageType: $packageType)",
|
"Should allow to unmute on start if not skipping lobby (callIntent: $callIntent, packageType: $packageType)",
|
||||||
({ callIntent, packageType }) => {
|
({ callIntent, isWidgetMode }) => {
|
||||||
const { audioEnabled, videoEnabled } = calculateInitialMuteState(
|
const { audioEnabled, videoEnabled } = calculateInitialMuteState(
|
||||||
false,
|
false,
|
||||||
callIntent,
|
callIntent,
|
||||||
packageType,
|
isWidgetMode,
|
||||||
);
|
);
|
||||||
expect(audioEnabled).toBe(true);
|
expect(audioEnabled).toBe(true);
|
||||||
expect(videoEnabled).toBe(callIntent !== "audio");
|
expect(videoEnabled).toBe(callIntent !== "audio");
|
||||||
@@ -40,12 +40,12 @@ test.each<{
|
|||||||
{ callIntent: "video" },
|
{ callIntent: "video" },
|
||||||
{ callIntent: "unknown" },
|
{ callIntent: "unknown" },
|
||||||
])(
|
])(
|
||||||
"Should always mute on start if skipping lobby on non embedded build (callIntent: $callIntent)",
|
"Should always mute on start if skipping lobby on non widget mode (callIntent: $callIntent)",
|
||||||
({ callIntent }) => {
|
({ callIntent }) => {
|
||||||
const { audioEnabled, videoEnabled } = calculateInitialMuteState(
|
const { audioEnabled, videoEnabled } = calculateInitialMuteState(
|
||||||
true,
|
true,
|
||||||
callIntent,
|
callIntent,
|
||||||
"full",
|
false,
|
||||||
);
|
);
|
||||||
expect(audioEnabled).toBe(false);
|
expect(audioEnabled).toBe(false);
|
||||||
expect(videoEnabled).toBe(false);
|
expect(videoEnabled).toBe(false);
|
||||||
@@ -59,43 +59,14 @@ test.each<{
|
|||||||
{ callIntent: "video" },
|
{ callIntent: "video" },
|
||||||
{ callIntent: "unknown" },
|
{ callIntent: "unknown" },
|
||||||
])(
|
])(
|
||||||
"Can start unmuted if skipping lobby on embedded build (callIntent: $callIntent)",
|
"Can start unmuted if skipping lobby on widget mode (callIntent: $callIntent)",
|
||||||
({ callIntent }) => {
|
({ callIntent }) => {
|
||||||
const { audioEnabled, videoEnabled } = calculateInitialMuteState(
|
const { audioEnabled, videoEnabled } = calculateInitialMuteState(
|
||||||
true,
|
true,
|
||||||
callIntent,
|
callIntent,
|
||||||
"embedded",
|
true,
|
||||||
);
|
);
|
||||||
expect(audioEnabled).toBe(true);
|
expect(audioEnabled).toBe(true);
|
||||||
expect(videoEnabled).toBe(callIntent !== "audio");
|
expect(videoEnabled).toBe(callIntent !== "audio");
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
test.each<{
|
|
||||||
isDevBuild: boolean;
|
|
||||||
currentHost: string;
|
|
||||||
expectedEnabled: boolean;
|
|
||||||
}>([
|
|
||||||
{ isDevBuild: true, currentHost: "localhost", expectedEnabled: true },
|
|
||||||
{ isDevBuild: false, currentHost: "localhost", expectedEnabled: false },
|
|
||||||
{ isDevBuild: true, currentHost: "call.example.com", expectedEnabled: false },
|
|
||||||
{
|
|
||||||
isDevBuild: false,
|
|
||||||
currentHost: "call.example.com",
|
|
||||||
expectedEnabled: false,
|
|
||||||
},
|
|
||||||
])(
|
|
||||||
"Should trust localhost domain when in dev mode isDevBuild($isDevBuild) host($currentHost)",
|
|
||||||
({ isDevBuild, currentHost, expectedEnabled }) => {
|
|
||||||
const { audioEnabled, videoEnabled } = calculateInitialMuteState(
|
|
||||||
true,
|
|
||||||
"video",
|
|
||||||
"full",
|
|
||||||
currentHost,
|
|
||||||
isDevBuild,
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(audioEnabled).toBe(expectedEnabled);
|
|
||||||
expect(videoEnabled).toBe(expectedEnabled);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|||||||
@@ -17,24 +17,15 @@ import { type RTCCallIntent } from "matrix-js-sdk/lib/matrixrtc";
|
|||||||
export function calculateInitialMuteState(
|
export function calculateInitialMuteState(
|
||||||
skipLobby: boolean,
|
skipLobby: boolean,
|
||||||
callIntent: RTCCallIntent | undefined,
|
callIntent: RTCCallIntent | undefined,
|
||||||
packageType: "full" | "embedded",
|
isWidgetMode: boolean,
|
||||||
hostname: string | undefined = undefined,
|
|
||||||
trustLocalhost: boolean = false,
|
|
||||||
): { audioEnabled: boolean; videoEnabled: boolean } {
|
): { audioEnabled: boolean; videoEnabled: boolean } {
|
||||||
|
|
||||||
logger.debug(
|
logger.debug(
|
||||||
`calculateInitialMuteState: skipLobby=${skipLobby}, callIntent=${callIntent}, hostname=${hostname}, trustLocalhost=${trustLocalhost}`,
|
`calculateInitialMuteState: skipLobby=${skipLobby}, callIntent=${callIntent} isWidgetMode=${isWidgetMode}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
const isTrustedHost =
|
if (skipLobby && !isWidgetMode) {
|
||||||
packageType == "embedded" ||
|
// If not in widget mode and lobby is skipped, default to muted to protect user privacy.
|
||||||
// Trust local hosts in dev mode to make local testing easier
|
// In the SPA context we don't want to unmute users without giving them a chance to adjust their settings first.
|
||||||
(hostname == "localhost" && trustLocalhost);
|
|
||||||
|
|
||||||
if (skipLobby && !isTrustedHost) {
|
|
||||||
// If host not trusted and lobby skipped, default to muted to protect user privacy.
|
|
||||||
// This prevents users from inadvertently joining with active audio/video
|
|
||||||
// when browser permissions were previously granted in a different context.
|
|
||||||
return {
|
return {
|
||||||
audioEnabled: false,
|
audioEnabled: false,
|
||||||
videoEnabled: false,
|
videoEnabled: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user