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

Commit

Permalink
Respect io.element.jitsi useFor1To1Calls in well-known (#112)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
t3chguy authored Oct 2, 2024
1 parent 2a183c7 commit e60d3bd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
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

0 comments on commit e60d3bd

Please sign in to comment.