Handle missing Element Call `brand` (#9376)

pull/28217/head
Šimon Brandner 2022-10-07 21:55:48 +02:00 committed by GitHub
parent 26a74a193f
commit 5680d13acf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 19 additions and 14 deletions

View File

@ -117,9 +117,9 @@ export interface IConfigOptions {
obey_asserted_identity?: boolean; // MSC3086
};
element_call: {
url: string;
use_exclusively: boolean;
brand: string;
url?: string;
use_exclusively?: boolean;
brand?: string;
};
logout_redirect_url?: string;

View File

@ -52,7 +52,7 @@ import { UPDATE_EVENT } from "../../../stores/AsyncStore";
import { isVideoRoom as calcIsVideoRoom } from "../../../utils/video-rooms";
import LegacyCallHandler, { LegacyCallHandlerEvent } from "../../../LegacyCallHandler";
import { useFeatureEnabled, useSettingValue } from "../../../hooks/useSettings";
import SdkConfig from "../../../SdkConfig";
import SdkConfig, { DEFAULTS } from "../../../SdkConfig";
import { useEventEmitterState, useTypedEventEmitterState } from "../../../hooks/useEventEmitter";
import { useWidgets } from "../right_panel/RoomSummaryCard";
import { WidgetType } from "../../../widgets/WidgetType";
@ -195,7 +195,7 @@ const VideoCallButton: FC<VideoCallButtonProps> = ({ room, busy, setBusy, behavi
let menu: JSX.Element | null = null;
if (menuOpen) {
const buttonRect = buttonRef.current!.getBoundingClientRect();
const brand = SdkConfig.get("element_call").brand;
const brand = SdkConfig.get("element_call").brand ?? DEFAULTS.element_call.brand;
menu = <IconizedContextMenu {...aboveLeftOf(buttonRect)} onFinished={closeMenu}>
<IconizedContextMenuOptionList>
<IconizedContextMenuOption label={_t("Video call (Jitsi)")} onClick={onJitsiClick} />
@ -230,7 +230,9 @@ const CallButtons: FC<CallButtonsProps> = ({ room }) => {
const groupCallsEnabled = useFeatureEnabled("feature_group_calls");
const videoRoomsEnabled = useFeatureEnabled("feature_video_rooms");
const isVideoRoom = useMemo(() => videoRoomsEnabled && calcIsVideoRoom(room), [videoRoomsEnabled, room]);
const useElementCallExclusively = useMemo(() => SdkConfig.get("element_call").use_exclusively, []);
const useElementCallExclusively = useMemo(() => {
return SdkConfig.get("element_call").use_exclusively ?? DEFAULTS.element_call.use_exclusively;
}, []);
const hasLegacyCall = useEventEmitterState(
LegacyCallHandler.instance,

View File

@ -32,7 +32,7 @@ import SettingsFieldset from '../../SettingsFieldset';
import SettingsStore from "../../../../../settings/SettingsStore";
import { VoiceBroadcastInfoEventType } from '../../../../../voice-broadcast';
import { ElementCall } from "../../../../../models/Call";
import SdkConfig from "../../../../../SdkConfig";
import SdkConfig, { DEFAULTS } from "../../../../../SdkConfig";
interface IEventShowOpts {
isState?: boolean;
@ -446,7 +446,7 @@ export default class RolesRoomSettingsTab extends React.Component<IProps> {
let label = plEventsToLabels[eventType];
if (label) {
const brand = SdkConfig.get("element_call").brand;
const brand = SdkConfig.get("element_call").brand ?? DEFAULTS.element_call.brand;
label = _t(label, { brand });
} else {
label = _t("Send %(eventType)s events", { eventType });

View File

@ -25,7 +25,7 @@ import SettingsSubsection from "../../shared/SettingsSubsection";
import SettingsTab from "../SettingsTab";
import { ElementCall } from "../../../../../models/Call";
import { useRoomState } from "../../../../../hooks/useRoomState";
import SdkConfig from "../../../../../SdkConfig";
import SdkConfig, { DEFAULTS } from "../../../../../SdkConfig";
interface ElementCallSwitchProps {
roomId: string;
@ -69,7 +69,7 @@ const ElementCallSwitch: React.FC<ElementCallSwitchProps> = ({ roomId }) => {
});
}, [roomId, content, events, isPublic]);
const brand = SdkConfig.get("element_call").brand;
const brand = SdkConfig.get("element_call").brand ?? DEFAULTS.element_call.brand;
return <LabelledToggleSwitch
data-testid="element-call-switch"

View File

@ -31,7 +31,7 @@ import type { Room } from "matrix-js-sdk/src/models/room";
import type { RoomMember } from "matrix-js-sdk/src/models/room-member";
import type { ClientWidgetApi } from "matrix-widget-api";
import type { IApp } from "../stores/WidgetStore";
import SdkConfig from "../SdkConfig";
import SdkConfig, { DEFAULTS } from "../SdkConfig";
import SettingsStore from "../settings/SettingsStore";
import MediaDeviceHandler, { MediaDeviceKindEnum } from "../MediaDeviceHandler";
import { timeout } from "../utils/promise";
@ -622,7 +622,7 @@ export class ElementCall extends Call {
private constructor(public readonly groupCall: MatrixEvent, client: MatrixClient) {
// Splice together the Element Call URL for this call
const url = new URL(SdkConfig.get("element_call").url);
const url = new URL(SdkConfig.get("element_call").url ?? DEFAULTS.element_call.url);
url.pathname = "/room";
const params = new URLSearchParams({
embed: "",

View File

@ -40,7 +40,7 @@ import { logger } from "matrix-js-sdk/src/logger";
import { THREAD_RELATION_TYPE } from "matrix-js-sdk/src/models/thread";
import { Direction } from "matrix-js-sdk/src/matrix";
import SdkConfig from "../../SdkConfig";
import SdkConfig, { DEFAULTS } from "../../SdkConfig";
import { iterableDiff, iterableIntersection } from "../../utils/iterables";
import { MatrixClientPeg } from "../../MatrixClientPeg";
import Modal from "../../Modal";
@ -104,7 +104,10 @@ export class StopGapWidgetDriver extends WidgetDriver {
// Auto-approve the legacy visibility capability. We send it regardless of capability.
// Widgets don't technically need to request this capability, but Scalar still does.
this.allowedCapabilities.add("visibility");
} else if (virtual && new URL(SdkConfig.get("element_call").url).origin === this.forWidget.origin) {
} else if (
virtual
&& new URL(SdkConfig.get("element_call").url ?? DEFAULTS.element_call.url).origin === this.forWidget.origin
) {
// This is a trusted Element Call widget that we control
this.allowedCapabilities.add(MatrixCapabilities.AlwaysOnScreen);
this.allowedCapabilities.add(MatrixCapabilities.MSC3846TurnServers);