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

Add config to skip widget_build_url for DM rooms #11044

Merged
merged 2 commits into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/IConfigOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export interface IConfigOptions {
};

widget_build_url?: string; // url called to replace jitsi/call widget creation
widget_build_url_ignore_dm?: boolean;
audio_stream_url?: string;
jitsi?: {
preferred_domain: string;
Expand Down
2 changes: 1 addition & 1 deletion src/LegacyCallHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ export default class LegacyCallHandler extends EventEmitter {
}

// We might be using managed hybrid widgets
if (isManagedHybridWidgetEnabled()) {
if (isManagedHybridWidgetEnabled(roomId)) {
await addManagedHybridWidget(roomId);
return;
}
Expand Down
1 change: 1 addition & 0 deletions src/utils/WellKnownUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const EMBEDDED_PAGES_WK_PROPERTY = "io.element.embedded_pages";
/* eslint-disable camelcase */
export interface ICallBehaviourWellKnown {
widget_build_url?: string;
ignore_dm?: boolean;
}

export interface IE2EEWellKnown {
Expand Down
20 changes: 15 additions & 5 deletions src/widgets/ManagedHybrid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { IStoredLayout, WidgetLayoutStore } from "../stores/widgets/WidgetLayout
import WidgetEchoStore from "../stores/WidgetEchoStore";
import WidgetStore from "../stores/WidgetStore";
import SdkConfig from "../SdkConfig";
import DMRoomMap from "../utils/DMRoomMap";

/* eslint-disable camelcase */
interface IManagedHybridWidgetData {
Expand All @@ -33,16 +34,25 @@ interface IManagedHybridWidgetData {
}
/* eslint-enable camelcase */

function getWidgetBuildUrl(): string | undefined {
function getWidgetBuildUrl(roomId: string): string | undefined {
const isDm = !!DMRoomMap.shared().getUserIdForRoomId(roomId);
if (SdkConfig.get().widget_build_url) {
if (isDm && SdkConfig.get().widget_build_url_ignore_dm) {
return undefined;
}
return SdkConfig.get().widget_build_url;
}

const wellKnown = getCallBehaviourWellKnown(MatrixClientPeg.get());
if (isDm && wellKnown?.ignore_dm) {
return undefined;
}
/* eslint-disable-next-line camelcase */
return getCallBehaviourWellKnown(MatrixClientPeg.get())?.widget_build_url;
return wellKnown?.widget_build_url;
}

export function isManagedHybridWidgetEnabled(): boolean {
return !!getWidgetBuildUrl();
export function isManagedHybridWidgetEnabled(roomId: string): boolean {
return !!getWidgetBuildUrl(roomId);
}

export async function addManagedHybridWidget(roomId: string): Promise<void> {
Expand All @@ -60,7 +70,7 @@ export async function addManagedHybridWidget(roomId: string): Promise<void> {

// Get widget data
/* eslint-disable-next-line camelcase */
const widgetBuildUrl = getWidgetBuildUrl();
const widgetBuildUrl = getWidgetBuildUrl(roomId);
if (!widgetBuildUrl) {
return;
}
Expand Down