mirror of
https://github.com/vector-im/element-call.git
synced 2026-08-29 21:15:19 +00:00
Re-add creation of room by visiting the URL
Creates an unencrypted room if you land on an old-style simple URL forn a room that doesn't exist.
This commit is contained in:
@@ -20,10 +20,12 @@ import { ClientEvent, MatrixClient } from "matrix-js-sdk/src/client";
|
|||||||
import { SyncState } from "matrix-js-sdk/src/sync";
|
import { SyncState } from "matrix-js-sdk/src/sync";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { MatrixRTCSession } from "matrix-js-sdk/src/matrixrtc/MatrixRTCSession";
|
import { MatrixRTCSession } from "matrix-js-sdk/src/matrixrtc/MatrixRTCSession";
|
||||||
|
import { MatrixError } from "matrix-js-sdk";
|
||||||
|
|
||||||
import type { Room } from "matrix-js-sdk/src/models/room";
|
import type { Room } from "matrix-js-sdk/src/models/room";
|
||||||
import type { GroupCall } from "matrix-js-sdk/src/webrtc/groupCall";
|
import type { GroupCall } from "matrix-js-sdk/src/webrtc/groupCall";
|
||||||
import { useEnableE2EE } from "../settings/useSetting";
|
import { useEnableE2EE } from "../settings/useSetting";
|
||||||
|
import { createRoom, isLocalRoomId, roomNameFromRoomId } from "../matrix-utils";
|
||||||
|
|
||||||
export type GroupCallLoaded = {
|
export type GroupCallLoaded = {
|
||||||
kind: "loaded";
|
kind: "loaded";
|
||||||
@@ -69,20 +71,40 @@ export const useLoadGroupCall = (
|
|||||||
// Also, we explicitly look up the room alias here. We previously just tried to
|
// Also, we explicitly look up the room alias here. We previously just tried to
|
||||||
// join anyway but the js-sdk recreates the room if you pass the alias for a
|
// join anyway but the js-sdk recreates the room if you pass the alias for a
|
||||||
// room you're already joined to (which it probably ought not to).
|
// room you're already joined to (which it probably ought not to).
|
||||||
const lookupResult = await client.getRoomIdForAlias(
|
try {
|
||||||
roomIdOrAlias.toLowerCase()
|
const lookupResult = await client.getRoomIdForAlias(
|
||||||
);
|
roomIdOrAlias.toLowerCase()
|
||||||
logger.info(`${roomIdOrAlias} resolved to ${lookupResult.room_id}`);
|
|
||||||
room = client.getRoom(lookupResult.room_id);
|
|
||||||
if (!room) {
|
|
||||||
logger.info(`Room ${lookupResult.room_id} not found, joining.`);
|
|
||||||
room = await client.joinRoom(lookupResult.room_id, {
|
|
||||||
viaServers: lookupResult.servers,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
logger.info(
|
|
||||||
`Already in room ${lookupResult.room_id}, not rejoining.`
|
|
||||||
);
|
);
|
||||||
|
logger.info(`${roomIdOrAlias} resolved to ${lookupResult.room_id}`);
|
||||||
|
room = client.getRoom(lookupResult.room_id);
|
||||||
|
if (!room) {
|
||||||
|
logger.info(`Room ${lookupResult.room_id} not found, joining.`);
|
||||||
|
room = await client.joinRoom(lookupResult.room_id, {
|
||||||
|
viaServers: lookupResult.servers,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
logger.info(
|
||||||
|
`Already in room ${lookupResult.room_id}, not rejoining.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
if (
|
||||||
|
isLocalRoomId(roomIdOrAlias, client) &&
|
||||||
|
(e as MatrixError).errcode === "M_NOT_FOUND"
|
||||||
|
) {
|
||||||
|
// legacy path: create an unencrypted room if the user lands on a URL for a room that
|
||||||
|
// doesn't exist
|
||||||
|
const result = await createRoom(
|
||||||
|
client,
|
||||||
|
roomNameFromRoomId(roomIdOrAlias),
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
|
await client.waitUntilRoomReadyForGroupCalls(result.roomId);
|
||||||
|
return client.getRoom(result.roomId)!;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// room IDs we just try to join by their ID, which will not work in the
|
// room IDs we just try to join by their ID, which will not work in the
|
||||||
|
|||||||
Reference in New Issue
Block a user