Make copy link button include a password
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
@@ -25,6 +25,7 @@ import styles from "./CallList.module.css";
|
|||||||
import { getRoomUrl } from "../matrix-utils";
|
import { getRoomUrl } from "../matrix-utils";
|
||||||
import { Body, Caption } from "../typography/Typography";
|
import { Body, Caption } from "../typography/Typography";
|
||||||
import { GroupCallRoom } from "./useGroupCallRooms";
|
import { GroupCallRoom } from "./useGroupCallRooms";
|
||||||
|
import { useRoomSharedKey } from "../e2ee/sharedKeyManagement";
|
||||||
|
|
||||||
interface CallListProps {
|
interface CallListProps {
|
||||||
rooms: GroupCallRoom[];
|
rooms: GroupCallRoom[];
|
||||||
@@ -35,13 +36,14 @@ export function CallList({ rooms, client, disableFacepile }: CallListProps) {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className={styles.callList}>
|
<div className={styles.callList}>
|
||||||
{rooms.map(({ roomAlias, roomName, avatarUrl, participants }) => (
|
{rooms.map(({ room, roomAlias, roomName, avatarUrl, participants }) => (
|
||||||
<CallTile
|
<CallTile
|
||||||
key={roomAlias}
|
key={roomAlias}
|
||||||
client={client}
|
client={client}
|
||||||
name={roomName}
|
name={roomName}
|
||||||
avatarUrl={avatarUrl}
|
avatarUrl={avatarUrl}
|
||||||
roomAlias={roomAlias}
|
roomAlias={roomAlias}
|
||||||
|
roomId={room.roomId}
|
||||||
participants={participants}
|
participants={participants}
|
||||||
disableFacepile={disableFacepile}
|
disableFacepile={disableFacepile}
|
||||||
/>
|
/>
|
||||||
@@ -60,6 +62,7 @@ interface CallTileProps {
|
|||||||
name: string;
|
name: string;
|
||||||
avatarUrl: string;
|
avatarUrl: string;
|
||||||
roomAlias: string;
|
roomAlias: string;
|
||||||
|
roomId: string;
|
||||||
participants: RoomMember[];
|
participants: RoomMember[];
|
||||||
client: MatrixClient;
|
client: MatrixClient;
|
||||||
disableFacepile?: boolean;
|
disableFacepile?: boolean;
|
||||||
@@ -68,10 +71,13 @@ function CallTile({
|
|||||||
name,
|
name,
|
||||||
avatarUrl,
|
avatarUrl,
|
||||||
roomAlias,
|
roomAlias,
|
||||||
|
roomId,
|
||||||
participants,
|
participants,
|
||||||
client,
|
client,
|
||||||
disableFacepile,
|
disableFacepile,
|
||||||
}: CallTileProps) {
|
}: CallTileProps) {
|
||||||
|
const [roomSharedKey] = useRoomSharedKey(roomId);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.callTile}>
|
<div className={styles.callTile}>
|
||||||
<Link
|
<Link
|
||||||
@@ -103,7 +109,7 @@ function CallTile({
|
|||||||
<CopyButton
|
<CopyButton
|
||||||
className={styles.copyButton}
|
className={styles.copyButton}
|
||||||
variant="icon"
|
variant="icon"
|
||||||
value={getRoomUrl(roomAlias)}
|
value={getRoomUrl(roomAlias, roomSharedKey)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import {
|
|||||||
import type { MatrixClient } from "matrix-js-sdk/src/client";
|
import type { MatrixClient } from "matrix-js-sdk/src/client";
|
||||||
import type { Room } from "matrix-js-sdk/src/models/room";
|
import type { Room } from "matrix-js-sdk/src/models/room";
|
||||||
import IndexedDBWorker from "./IndexedDBWorker?worker";
|
import IndexedDBWorker from "./IndexedDBWorker?worker";
|
||||||
import { getUrlParams } from "./UrlParams";
|
import { getUrlParams, PASSWORD_STRING } from "./UrlParams";
|
||||||
import { loadOlm } from "./olm";
|
import { loadOlm } from "./olm";
|
||||||
import { Config } from "./config/Config";
|
import { Config } from "./config/Config";
|
||||||
|
|
||||||
@@ -343,13 +343,20 @@ export async function createRoom(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Returns a URL to that will load Element Call with the given room
|
// Returns a URL to that will load Element Call with the given room
|
||||||
export function getRoomUrl(roomIdOrAlias: string): string {
|
export function getRoomUrl(
|
||||||
|
roomIdOrAlias: string,
|
||||||
|
password: string = ""
|
||||||
|
): string {
|
||||||
if (roomIdOrAlias.startsWith("#")) {
|
if (roomIdOrAlias.startsWith("#")) {
|
||||||
return `${window.location.protocol}//${window.location.host}/${
|
return `${window.location.protocol}//${window.location.host}/${
|
||||||
roomIdOrAlias.substring(1).split(":")[0]
|
roomIdOrAlias.substring(1).split(":")[0]
|
||||||
}`;
|
}${password === "" ? "" : PASSWORD_STRING + password}`;
|
||||||
} else {
|
} else {
|
||||||
return `${window.location.protocol}//${window.location.host}/room?roomId=${roomIdOrAlias}`;
|
return `${window.location.protocol}//${
|
||||||
|
window.location.host
|
||||||
|
}/room?roomId=${roomIdOrAlias}${
|
||||||
|
password === "" ? "" : "#" + PASSWORD_STRING + password
|
||||||
|
}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -462,9 +462,8 @@ export function InCallView({
|
|||||||
)}
|
)}
|
||||||
{inviteModalState.isOpen && (
|
{inviteModalState.isOpen && (
|
||||||
<InviteModal
|
<InviteModal
|
||||||
roomIdOrAlias={
|
roomAlias={groupCall.room.getCanonicalAlias() ?? undefined}
|
||||||
groupCall.room.getCanonicalAlias() ?? groupCall.room.roomId
|
roomId={groupCall.room.roomId}
|
||||||
}
|
|
||||||
{...inviteModalProps}
|
{...inviteModalProps}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2022 New Vector Ltd
|
Copyright 2022 - 2023 New Vector Ltd
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -21,13 +21,16 @@ import { Modal, ModalContent, ModalProps } from "../Modal";
|
|||||||
import { CopyButton } from "../button";
|
import { CopyButton } from "../button";
|
||||||
import { getRoomUrl } from "../matrix-utils";
|
import { getRoomUrl } from "../matrix-utils";
|
||||||
import styles from "./InviteModal.module.css";
|
import styles from "./InviteModal.module.css";
|
||||||
|
import { useRoomSharedKey } from "../e2ee/sharedKeyManagement";
|
||||||
|
|
||||||
interface Props extends Omit<ModalProps, "title" | "children"> {
|
interface Props extends Omit<ModalProps, "title" | "children"> {
|
||||||
roomIdOrAlias: string;
|
roomAlias?: string;
|
||||||
|
roomId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const InviteModal: FC<Props> = ({ roomIdOrAlias, ...rest }) => {
|
export const InviteModal: FC<Props> = ({ roomAlias, roomId, ...rest }) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const [roomSharedKey] = useRoomSharedKey(roomId);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
@@ -40,7 +43,7 @@ export const InviteModal: FC<Props> = ({ roomIdOrAlias, ...rest }) => {
|
|||||||
<p>{t("Copy and share this call link")}</p>
|
<p>{t("Copy and share this call link")}</p>
|
||||||
<CopyButton
|
<CopyButton
|
||||||
className={styles.copyButton}
|
className={styles.copyButton}
|
||||||
value={getRoomUrl(roomIdOrAlias)}
|
value={getRoomUrl(roomAlias ?? roomId, roomSharedKey)}
|
||||||
data-testid="modal_inviteLink"
|
data-testid="modal_inviteLink"
|
||||||
/>
|
/>
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import { Body, Link } from "../typography/Typography";
|
|||||||
import { useLocationNavigation } from "../useLocationNavigation";
|
import { useLocationNavigation } from "../useLocationNavigation";
|
||||||
import { MatrixInfo, VideoPreview } from "./VideoPreview";
|
import { MatrixInfo, VideoPreview } from "./VideoPreview";
|
||||||
import { MuteStates } from "./MuteStates";
|
import { MuteStates } from "./MuteStates";
|
||||||
|
import { useRoomSharedKey } from "../e2ee/sharedKeyManagement";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
matrixInfo: MatrixInfo;
|
matrixInfo: MatrixInfo;
|
||||||
@@ -43,6 +44,7 @@ export const LobbyView: FC<Props> = ({
|
|||||||
hideHeader,
|
hideHeader,
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const [roomSharedKey] = useRoomSharedKey(matrixInfo.roomId);
|
||||||
useLocationNavigation();
|
useLocationNavigation();
|
||||||
|
|
||||||
const joinCallButtonRef = useRef<HTMLButtonElement>(null);
|
const joinCallButtonRef = useRef<HTMLButtonElement>(null);
|
||||||
@@ -80,7 +82,10 @@ export const LobbyView: FC<Props> = ({
|
|||||||
<Body>Or</Body>
|
<Body>Or</Body>
|
||||||
<CopyButton
|
<CopyButton
|
||||||
variant="secondaryCopy"
|
variant="secondaryCopy"
|
||||||
value={getRoomUrl(matrixInfo.roomAlias ?? matrixInfo.roomId)}
|
value={getRoomUrl(
|
||||||
|
matrixInfo.roomAlias ?? matrixInfo.roomId,
|
||||||
|
roomSharedKey
|
||||||
|
)}
|
||||||
className={styles.copyButton}
|
className={styles.copyButton}
|
||||||
copiedMessage={t("Call link copied")}
|
copiedMessage={t("Call link copied")}
|
||||||
data-testid="lobby_inviteLink"
|
data-testid="lobby_inviteLink"
|
||||||
|
|||||||
Reference in New Issue
Block a user