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

Commit e60d3bd

Browse files
authored
Respect io.element.jitsi useFor1To1Calls in well-known (#112)
* Respect `io.element.jitsi` `useFor1To1Calls` in well-known Signed-off-by: Michael Telatynski <[email protected]> * Iterate Signed-off-by: Michael Telatynski <[email protected]> --------- Signed-off-by: Michael Telatynski <[email protected]>
1 parent 2a183c7 commit e60d3bd

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/LegacyCallHandler.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ import { SdkContextClass } from "./contexts/SDKContext";
5959
import { showCantStartACallDialog } from "./voice-broadcast/utils/showCantStartACallDialog";
6060
import { isNotNull } from "./Typeguards";
6161
import { BackgroundAudio } from "./audio/BackgroundAudio";
62+
import { Jitsi } from "./widgets/Jitsi.ts";
6263

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

914915
await this.placeMatrixCall(roomId, type, transferee);
915916
} else {
916-
// > 2
917+
// > 2 || useFor1To1Calls
917918
await this.placeJitsiCall(roomId, type);
918919
}
919920
}

src/widgets/Jitsi.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import { ClientEvent, IClientWellKnown } from "matrix-js-sdk/src/matrix";
1212
import SdkConfig from "../SdkConfig";
1313
import { MatrixClientPeg } from "../MatrixClientPeg";
1414

15-
const JITSI_WK_PROPERTY = "im.vector.riot.jitsi";
15+
const JITSI_WK_PROPERTY_LEGACY = "im.vector.riot.jitsi";
16+
const JITSI_WK_PROPERTY = "io.element.jitsi";
1617

1718
export interface JitsiWidgetData {
1819
conferenceId: string;
@@ -24,11 +25,16 @@ export class Jitsi {
2425
private static instance: Jitsi;
2526

2627
private domain?: string;
28+
private _useFor1To1Calls = false;
2729

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

34+
public get useFor1To1Calls(): boolean {
35+
return this._useFor1To1Calls;
36+
}
37+
3238
/**
3339
* Checks for auth needed by looking up a well-known file
3440
*
@@ -65,12 +71,16 @@ export class Jitsi {
6571
let domain = SdkConfig.getObject("jitsi")?.get("preferred_domain") || "meet.element.io";
6672

6773
logger.log("Attempting to get Jitsi conference information from homeserver");
68-
const wkPreferredDomain = discoveryResponse?.[JITSI_WK_PROPERTY]?.["preferredDomain"];
74+
const wkJitsiConfig = discoveryResponse?.[JITSI_WK_PROPERTY] ?? discoveryResponse?.[JITSI_WK_PROPERTY_LEGACY];
75+
76+
const wkPreferredDomain = wkJitsiConfig?.["preferredDomain"];
6977
if (wkPreferredDomain) domain = wkPreferredDomain;
7078

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

7686
/**

0 commit comments

Comments
 (0)