mirror of
https://github.com/vector-im/element-call.git
synced 2024-11-15 00:04:59 +08:00
More URL handling adjustements
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
parent
506b363f38
commit
b2f5f90f37
@ -108,8 +108,11 @@ export const getUrlParams = (
|
|||||||
pathname = window.location.pathname,
|
pathname = window.location.pathname,
|
||||||
hash = window.location.hash
|
hash = window.location.hash
|
||||||
): UrlParams => {
|
): UrlParams => {
|
||||||
|
// This is legacy code - we're moving away from using aliases
|
||||||
let roomAlias: string | null = null;
|
let roomAlias: string | null = null;
|
||||||
if (!ignoreRoomAlias) {
|
if (!ignoreRoomAlias) {
|
||||||
|
// Here we handle the beginning of the alias and make sure it starts with a
|
||||||
|
// "#"
|
||||||
if (hash === "" || hash.startsWith("#?")) {
|
if (hash === "" || hash.startsWith("#?")) {
|
||||||
roomAlias = pathname.substring(1); // Strip the "/"
|
roomAlias = pathname.substring(1); // Strip the "/"
|
||||||
|
|
||||||
@ -125,17 +128,17 @@ export const getUrlParams = (
|
|||||||
roomAlias = hash;
|
roomAlias = hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete "?" and what comes afterwards
|
||||||
|
roomAlias = roomAlias.split("?")[0];
|
||||||
|
|
||||||
|
if (roomAlias.length <= 1) {
|
||||||
|
// Make roomAlias is null, if it only is a "#"
|
||||||
|
roomAlias = null;
|
||||||
|
} else {
|
||||||
// Add server part, if not present
|
// Add server part, if not present
|
||||||
if (!roomAlias.includes(":")) {
|
if (!roomAlias.includes(":")) {
|
||||||
roomAlias = `${roomAlias}:${Config.defaultServerName()}`;
|
roomAlias = `${roomAlias}:${Config.defaultServerName()}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete "?" and what comes afterwards
|
|
||||||
roomAlias = roomAlias.split("?")[0];
|
|
||||||
|
|
||||||
// Make roomAlias undefined, if empty
|
|
||||||
if (roomAlias.length <= 1) {
|
|
||||||
roomAlias = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,14 +273,15 @@ export function isLocalRoomId(roomId: string, client: MatrixClient): boolean {
|
|||||||
export async function createRoom(
|
export async function createRoom(
|
||||||
client: MatrixClient,
|
client: MatrixClient,
|
||||||
name: string,
|
name: string,
|
||||||
ptt: boolean
|
ptt: boolean,
|
||||||
|
e2ee: boolean
|
||||||
): Promise<[string, string]> {
|
): Promise<[string, string]> {
|
||||||
logger.log(`Creating room for group call`);
|
logger.log(`Creating room for group call`);
|
||||||
const createPromise = client.createRoom({
|
const createPromise = client.createRoom({
|
||||||
visibility: Visibility.Private,
|
visibility: Visibility.Private,
|
||||||
preset: Preset.PublicChat,
|
preset: Preset.PublicChat,
|
||||||
name,
|
name,
|
||||||
room_alias_name: roomAliasLocalpartFromRoomName(name),
|
room_alias_name: e2ee ? undefined : roomAliasLocalpartFromRoomName(name),
|
||||||
power_level_content_override: {
|
power_level_content_override: {
|
||||||
invite: 100,
|
invite: 100,
|
||||||
kick: 100,
|
kick: 100,
|
||||||
@ -342,20 +343,16 @@ export async function createRoom(
|
|||||||
return [fullAliasFromRoomName(name, client), result.room_id];
|
return [fullAliasFromRoomName(name, client), result.room_id];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a URL to that will load Element Call with the given room
|
/**
|
||||||
export function getRoomUrl(
|
* Returns a URL to that will load Element Call with the given room
|
||||||
roomIdOrAlias: string,
|
* @param roomId of the room
|
||||||
password: string = ""
|
* @param password
|
||||||
): string {
|
* @returns
|
||||||
password = password === "" ? "" : "#?" + PASSWORD_STRING + password;
|
*/
|
||||||
|
export function getRoomUrl(roomId: string, password?: string): string {
|
||||||
if (roomIdOrAlias.startsWith("#")) {
|
return `${window.location.protocol}//${
|
||||||
return `${window.location.protocol}//${window.location.host}/${
|
window.location.host
|
||||||
roomIdOrAlias.substring(1).split(":")[0]
|
}/room/#?roomId=${roomId}${password ? "&" + PASSWORD_STRING + password : ""}`;
|
||||||
}${password}`;
|
|
||||||
} else {
|
|
||||||
return `${window.location.protocol}//${window.location.host}/room?roomId=${roomIdOrAlias}${password}`;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getAvatarUrl(
|
export function getAvatarUrl(
|
||||||
|
Loading…
Reference in New Issue
Block a user