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

* Respect `io.element.jitsi` `useFor1To1Calls` in well-known

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Iterate

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

---------

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
pull/28192/head
Michael Telatynski 2024-10-02 12:36:11 +01:00 committed by GitHub
parent 2a183c76c9
commit e60d3bd1ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 4 deletions

View File

@ -59,6 +59,7 @@ import { SdkContextClass } from "./contexts/SDKContext";
import { showCantStartACallDialog } from "./voice-broadcast/utils/showCantStartACallDialog"; import { showCantStartACallDialog } from "./voice-broadcast/utils/showCantStartACallDialog";
import { isNotNull } from "./Typeguards"; import { isNotNull } from "./Typeguards";
import { BackgroundAudio } from "./audio/BackgroundAudio"; import { BackgroundAudio } from "./audio/BackgroundAudio";
import { Jitsi } from "./widgets/Jitsi.ts";
export const PROTOCOL_PSTN = "m.protocol.pstn"; export const PROTOCOL_PSTN = "m.protocol.pstn";
export const PROTOCOL_PSTN_PREFIXED = "im.vector.protocol.pstn"; export const PROTOCOL_PSTN_PREFIXED = "im.vector.protocol.pstn";
@ -908,12 +909,12 @@ export default class LegacyCallHandler extends EventEmitter {
Modal.createDialog(ErrorDialog, { Modal.createDialog(ErrorDialog, {
description: _t("voip|cannot_call_yourself_description"), 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}`); logger.info(`Place ${type} call in ${roomId}`);
await this.placeMatrixCall(roomId, type, transferee); await this.placeMatrixCall(roomId, type, transferee);
} else { } else {
// > 2 // > 2 || useFor1To1Calls
await this.placeJitsiCall(roomId, type); await this.placeJitsiCall(roomId, type);
} }
} }

View File

@ -12,7 +12,8 @@ import { ClientEvent, IClientWellKnown } from "matrix-js-sdk/src/matrix";
import SdkConfig from "../SdkConfig"; import SdkConfig from "../SdkConfig";
import { MatrixClientPeg } from "../MatrixClientPeg"; 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 { export interface JitsiWidgetData {
conferenceId: string; conferenceId: string;
@ -24,11 +25,16 @@ export class Jitsi {
private static instance: Jitsi; private static instance: Jitsi;
private domain?: string; private domain?: string;
private _useFor1To1Calls = false;
public get preferredDomain(): string { public get preferredDomain(): string {
return this.domain || "meet.element.io"; return this.domain || "meet.element.io";
} }
public get useFor1To1Calls(): boolean {
return this._useFor1To1Calls;
}
/** /**
* Checks for auth needed by looking up a well-known file * Checks for auth needed by looking up a well-known file
* *
@ -65,12 +71,16 @@ export class Jitsi {
let domain = SdkConfig.getObject("jitsi")?.get("preferred_domain") || "meet.element.io"; let domain = SdkConfig.getObject("jitsi")?.get("preferred_domain") || "meet.element.io";
logger.log("Attempting to get Jitsi conference information from homeserver"); 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; if (wkPreferredDomain) domain = wkPreferredDomain;
// Put the result into memory for us to use later // Put the result into memory for us to use later
this.domain = domain; this.domain = domain;
logger.log("Jitsi conference domain:", this.preferredDomain); logger.log("Jitsi conference domain:", this.preferredDomain);
this._useFor1To1Calls = wkJitsiConfig?.["useFor1To1Calls"] || false;
logger.log("Jitsi use for 1:1 calls:", this.useFor1To1Calls);
}; };
/** /**