Knocking support (#2281)

* Add joining with knock room creation flow.

Also add `WaitForInviteView` after knocking.
And appropriate error views when knock failed or gets rejected.

Signed-off-by: Timo K <toger5@hotmail.de>

* Refactor encryption information.

We had lots of enums and booleans to describe the encryption situation.
Now we only use the `EncryptionSystem` "enum" which contains the
additional information like sharedKey. (and we don't use the isRoomE2EE
function that is somewhat confusing since it checks `return widget ===
null && !room.getCanonicalAlias();` which is only indirectly related to
e2ee)

Signed-off-by: Timo K <toger5@hotmail.de>

* Update recent list.

- Don't use deprecated `groupCallEventHander` anymore (it used the old
  `m.call` state event.)
- make the recent list reactive (getting removed from a call removes the
  item from the list)
- support having rooms without shared secret but actual matrix
  encryption in the recent list
- change the share link creation button so that we create a link with
  pwd for sharedKey rooms and with `perParticipantE2EE=true` for matrix
  encrypted rooms.

Signed-off-by: Timo K <toger5@hotmail.de>

* fix types

Signed-off-by: Timo K <toger5@hotmail.de>

* patch js-sdk for linter

Signed-off-by: Timo K <toger5@hotmail.de>

* ignore ts expect error

Signed-off-by: Timo K <toger5@hotmail.de>

* Fix error in widget mode.

We cannot call client.getRoomSummary in widget mode. The code path needs
to throw before reaching this call. (In general we should never call
getRoomSummary if getRoom returns a room)

Signed-off-by: Timo K <toger5@hotmail.de>

* tempDemo

Signed-off-by: Timo K <toger5@hotmail.de>

* remove wait for invite view

Signed-off-by: Timo K <toger5@hotmail.de>

* yarn i18n

Signed-off-by: Timo K <toger5@hotmail.de>

* reset back mute participant count

* add logic to show error view when getting removed

* include reason whenever someone gets removed from a call.

* fix activeRoom not beeing early enough

* fix lints

* add comment about encryption situation

Signed-off-by: Timo K <toger5@hotmail.de>

* Fix lockfile

* Use (unmerged!) RoomSummary type from the js-sdk

Temporarily change the js-sdk dependency to the PR branch that provides
that type

* review

Signed-off-by: Timo K <toger5@hotmail.de>

* review (remove participant count unknown)

Signed-off-by: Timo K <toger5@hotmail.de>

* remove error for unencrypted calls (allow intentional unencrypted calls)

Signed-off-by: Timo K <toger5@hotmail.de>

* update js-sdk

Signed-off-by: Timo K <toger5@hotmail.de>

---------

Signed-off-by: Timo K <toger5@hotmail.de>
Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
This commit is contained in:
Timo
2024-04-23 15:15:13 +02:00
committed by GitHub
parent be25d77e8b
commit 5284479ece
26 changed files with 631 additions and 299 deletions

View File

@@ -24,20 +24,16 @@ import { ClientEvent } from "matrix-js-sdk/src/client";
import { Visibility, Preset } from "matrix-js-sdk/src/@types/partials";
import { ISyncStateData, SyncState } from "matrix-js-sdk/src/sync";
import { logger } from "matrix-js-sdk/src/logger";
import {
GroupCallIntent,
GroupCallType,
} from "matrix-js-sdk/src/webrtc/groupCall";
import { secureRandomBase64Url } from "matrix-js-sdk/src/randomstring";
import type { MatrixClient } from "matrix-js-sdk/src/client";
import type { Room } from "matrix-js-sdk/src/models/room";
import IndexedDBWorker from "./IndexedDBWorker?worker";
import { getUrlParams, PASSWORD_STRING } from "./UrlParams";
import { generateUrlSearchParams, getUrlParams } from "./UrlParams";
import { loadOlm } from "./olm";
import { Config } from "./config/Config";
import { E2eeType } from "./e2ee/e2eeType";
import { saveKeyForRoom } from "./e2ee/sharedKeyManagement";
import { EncryptionSystem, saveKeyForRoom } from "./e2ee/sharedKeyManagement";
export const fallbackICEServerAllowed =
import.meta.env.VITE_FALLBACK_STUN_ALLOWED === "true";
@@ -338,16 +334,6 @@ export async function createRoom(
const result = await createPromise;
logger.log(`Creating group call in ${result.room_id}`);
await client.createGroupCall(
result.room_id,
GroupCallType.Video,
false,
GroupCallIntent.Room,
true,
);
let password;
if (e2ee == E2eeType.SHARED_KEY) {
password = secureRandomBase64Url(16);
@@ -365,39 +351,35 @@ export async function createRoom(
* Returns an absolute URL to that will load Element Call with the given room
* @param roomId ID of the room
* @param roomName Name of the room
* @param password e2e key for the room
* @param encryptionSystem what encryption (or EncryptionSystem.Unencrypted) the room uses
*/
export function getAbsoluteRoomUrl(
roomId: string,
encryptionSystem: EncryptionSystem,
roomName?: string,
password?: string,
viaServers?: string[],
): string {
return `${window.location.protocol}//${
window.location.host
}${getRelativeRoomUrl(roomId, roomName, password)}`;
}${getRelativeRoomUrl(roomId, encryptionSystem, roomName, viaServers)}`;
}
/**
* Returns a relative URL to that will load Element Call with the given room
* @param roomId ID of the room
* @param roomName Name of the room
* @param password e2e key for the room
* @param encryptionSystem what encryption (or EncryptionSystem.Unencrypted) the room uses
*/
export function getRelativeRoomUrl(
roomId: string,
encryptionSystem: EncryptionSystem,
roomName?: string,
password?: string,
viaServers?: string[],
): string {
// The password shouldn't need URL encoding here (we generate URL-safe ones) but encode
// it in case it came from another client that generated a non url-safe one
const encodedPassword = password ? encodeURIComponent(password) : undefined;
if (password && encodedPassword !== password) {
logger.info("Encoded call password used non URL-safe chars: buggy client?");
}
return `/room/#${
roomName ? "/" + roomAliasLocalpartFromRoomName(roomName) : ""
}?roomId=${roomId}${password ? "&" + PASSWORD_STRING + encodedPassword : ""}`;
const roomPart = roomName
? "/" + roomAliasLocalpartFromRoomName(roomName)
: "";
return `/room/#${roomPart}?${generateUrlSearchParams(roomId, encryptionSystem, viaServers).toString()}`;
}
export function getAvatarUrl(