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>
This commit is contained in:
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 { 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";
@ -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);
}
}

View file

@ -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;
@ -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
*
@ -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);
};
/**