Skip to content
This repository was archived by the owner on Oct 22, 2024. It is now read-only.

Respect io.element.jitsi useFor1To1Calls in well-known #112

Merged
merged 2 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 3 additions & 2 deletions src/LegacyCallHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import { SdkContextClass } from "./contexts/SDKContext";
import { showCantStartACallDialog } from "./voice-broadcast/utils/showCantStartACallDialog";
import { isNotNull } from "./Typeguards";
import { BackgroundAudio } from "./audio/BackgroundAudio";
import { Jitsi } from "./widgets/Jitsi.ts";

export const PROTOCOL_PSTN = "m.protocol.pstn";
export const PROTOCOL_PSTN_PREFIXED = "im.vector.protocol.pstn";
Expand Down Expand Up @@ -908,12 +909,12 @@ export default class LegacyCallHandler extends EventEmitter {
Modal.createDialog(ErrorDialog, {
description: _t("voip|cannot_call_yourself_description"),
});
} else if (members.length === 2) {
} else if (members.length === 2 && !Jitsi.getInstance().useFor1To1Calls) {
logger.info(`Place ${type} call in ${roomId}`);

await this.placeMatrixCall(roomId, type, transferee);
} else {
// > 2
// > 2 || useFor1To1Calls
await this.placeJitsiCall(roomId, type);
}
}
Expand Down
14 changes: 12 additions & 2 deletions src/widgets/Jitsi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import { ClientEvent, IClientWellKnown } from "matrix-js-sdk/src/matrix";
import SdkConfig from "../SdkConfig";
import { MatrixClientPeg } from "../MatrixClientPeg";

const JITSI_WK_PROPERTY = "im.vector.riot.jitsi";
const JITSI_WK_PROPERTY_LEGACY = "im.vector.riot.jitsi";
const JITSI_WK_PROPERTY = "io.element.jitsi";

export interface JitsiWidgetData {
conferenceId: string;
Expand All @@ -24,11 +25,16 @@ export class Jitsi {
private static instance: Jitsi;

private domain?: string;
private _useFor1To1Calls = false;

public get preferredDomain(): string {
return this.domain || "meet.element.io";
}

public get useFor1To1Calls(): boolean {
return this._useFor1To1Calls;
}

/**
* Checks for auth needed by looking up a well-known file
*
Expand Down Expand Up @@ -65,12 +71,16 @@ export class Jitsi {
let domain = SdkConfig.getObject("jitsi")?.get("preferred_domain") || "meet.element.io";

logger.log("Attempting to get Jitsi conference information from homeserver");
const wkPreferredDomain = discoveryResponse?.[JITSI_WK_PROPERTY]?.["preferredDomain"];
const wkJitsiConfig = discoveryResponse?.[JITSI_WK_PROPERTY] ?? discoveryResponse?.[JITSI_WK_PROPERTY_LEGACY];

const wkPreferredDomain = wkJitsiConfig?.["preferredDomain"];
if (wkPreferredDomain) domain = wkPreferredDomain;

// Put the result into memory for us to use later
this.domain = domain;
logger.log("Jitsi conference domain:", this.preferredDomain);
this._useFor1To1Calls = wkJitsiConfig?.["useFor1To1Calls"] || false;
logger.log("Jitsi use for 1:1 calls:", this.useFor1To1Calls);
};

/**
Expand Down
Loading