Compare commits

...

6 Commits

Author SHA1 Message Date
Will Hunt
35569f35bb Don't template skipLobby or returnToLobby but inject as required 2025-09-11 17:12:09 +01:00
Will Hunt
2f4d845f20 cleanup 2025-09-11 16:45:40 +01:00
Will Hunt
cf7d3a4141 Remove hacks 2025-09-11 15:28:34 +01:00
Will Hunt
1e342c6200 Do not default skipLobby in Element Web 2025-09-11 15:28:18 +01:00
Half-Shot
8025ab47b2 Refactor and fix intent bugs 2025-09-11 09:29:01 +01:00
Half-Shot
a613180927 Start to implement intents for DM calls. 2025-09-11 08:24:36 +01:00

View File

@@ -542,6 +542,13 @@ export class JitsiCall extends Call {
};
}
export enum ElementCallIntent {
StartCall = "start_call",
JoinExisting = "join_existing",
StartCallDM = "start_call_dm",
JoinExistingDM = "join_existing_dm",
}
/**
* A group call using MSC3401 and Element Call as a backend.
* (somewhat cheekily named)
@@ -560,7 +567,7 @@ export class ElementCall extends Call {
this.checkDestroy();
}
private static generateWidgetUrl(client: MatrixClient, roomId: string): URL {
private static generateWidgetUrl(client: MatrixClient, roomId: string, data: {skipLobby?: boolean, returnToLobby?: boolean} = {}): URL {
const baseUrl = window.location.href;
let url = new URL("./widgets/element-call/index.html#", baseUrl); // this strips hash fragment from baseUrl
@@ -571,8 +578,6 @@ export class ElementCall extends Call {
const params = new URLSearchParams({
confineToRoom: "true", // Only show the call interface for the configured room
// Template variables are used, so that this can be configured using the widget data.
skipLobby: "$skipLobby", // Skip the lobby in case we show a lobby component of our own.
returnToLobby: "$returnToLobby", // Returns to the lobby (instead of blank screen) when the call ends. (For video rooms)
perParticipantE2EE: "$perParticipantE2EE",
header: "none", // Hide the header since our room header is enough
userId: client.getUserId()!,
@@ -584,12 +589,28 @@ export class ElementCall extends Call {
theme: "$org.matrix.msc2873.client_theme",
});
if (typeof data.skipLobby === "boolean") {
params.append("skipLobby", data.skipLobby.toString());
}
if (typeof data.returnToLobby === "boolean") {
params.append("returnToLobby", data.returnToLobby.toString());
}
const room = client.getRoom(roomId);
if (room !== null && !isVideoRoom(room)) {
params.append(
"sendNotificationType",
RoomListStore.instance.getTagsForRoom(room).includes(DefaultTagID.DM) ? "ring" : "notification",
);
const isDM = RoomListStore.instance.getTagsForRoom(room).includes(DefaultTagID.DM);
params.append("sendNotificationType", isDM ? "ring" : "notification");
if (isDM) {
const oldestMembership = client.matrixRTC.getRoomSession(room).getOldestMembership();
if (!oldestMembership) {
// We are starting a call
params.append("intent", ElementCallIntent.StartCallDM);
} else if (oldestMembership.sender !== client.getSafeUserId()) {
// We are joining a call.
params.append("intent", ElementCallIntent.JoinExistingDM);
} // else, don't set an intent.
}
}
const rageshakeSubmitUrl = SdkConfig.get("bug_report_endpoint_url");
@@ -648,7 +669,6 @@ export class ElementCall extends Call {
}
// Creates a new widget if there isn't any widget of typ Call in this room.
// Defaults for creating a new widget are: skipLobby = false
// When there is already a widget the current widget configuration will be used or can be overwritten
// by passing the according parameters (skipLobby).
private static createOrGetCallWidget(
@@ -674,7 +694,7 @@ export class ElementCall extends Call {
// To use Element Call without touching room state, we create a virtual
// widget (one that doesn't have a corresponding state event)
const url = ElementCall.generateWidgetUrl(client, roomId);
const url = ElementCall.generateWidgetUrl(client, roomId, { skipLobby, returnToLobby });
const createdWidget = WidgetStore.instance.addVirtualWidget(
{
id: secureRandomString(24), // So that it's globally unique
@@ -687,10 +707,6 @@ export class ElementCall extends Call {
client,
roomId,
{},
{
skipLobby: skipLobby ?? false,
returnToLobby: returnToLobby ?? false,
},
),
},
roomId,
@@ -703,7 +719,7 @@ export class ElementCall extends Call {
client: MatrixClient,
roomId: string,
currentData: IWidgetData,
overwriteData: IWidgetData,
overwriteData: IWidgetData = {},
): IWidgetData {
let perParticipantE2EE = false;
if (