From 2977038b6b5abd84fa19d999e3cee66a2b564d69 Mon Sep 17 00:00:00 2001 From: Timo K Date: Tue, 16 Sep 2025 10:13:14 +0200 Subject: [PATCH] enable encryption in per sender case Signed-off-by: Timo K --- src/room/GroupCallView.tsx | 1 + src/state/CallViewModel.ts | 46 ++++++++++++++++++++------------------ 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/room/GroupCallView.tsx b/src/room/GroupCallView.tsx index e8582ae1..35308272 100644 --- a/src/room/GroupCallView.tsx +++ b/src/room/GroupCallView.tsx @@ -349,6 +349,7 @@ export const GroupCallView: FC = ({ window.setTimeout(resolve, 10); }); + // TODO-MULTI-SFU find a solution if this is supposed to happen here or in the view model. leaveRTCSession( rtcSession, cause, diff --git a/src/state/CallViewModel.ts b/src/state/CallViewModel.ts index 242206fb..d31c95ca 100644 --- a/src/state/CallViewModel.ts +++ b/src/state/CallViewModel.ts @@ -8,6 +8,7 @@ Please see LICENSE in the repository root for full details. import { observeParticipantEvents } from "@livekit/components-core"; import { type BaseKeyProvider, + type E2EEOptions, ExternalE2EEKeyProvider, type Room as LivekitRoom, type LocalParticipant, @@ -414,6 +415,13 @@ export class CallViewModel extends ViewModel { this.options.encryptionSystem, this.matrixRTCSession, ); + private readonly e2eeLivekitOptions = (): E2EEOptions | undefined => + this.livekitE2EEKeyProvider + ? { + keyProvider: this.livekitE2EEKeyProvider, + worker: new E2EEWorker(), + } + : undefined; private readonly localFocus = makeFocus(this.matrixRTCSession); @@ -427,12 +435,7 @@ export class CallViewModel extends ViewModel { this.membershipsAndFocusMap$, this.mediaDevices, this.muteStates, - this.livekitE2EEKeyProvider - ? { - keyProvider: this.livekitE2EEKeyProvider, - worker: new E2EEWorker(), - } - : undefined, + this.e2eeLivekitOptions(), ), ); @@ -488,12 +491,7 @@ export class CallViewModel extends ViewModel { this.matrixRTCSession.room.client, this.scope, this.membershipsAndFocusMap$, - this.livekitE2EEKeyProvider - ? { - keyProvider: this.livekitE2EEKeyProvider, - worker: new E2EEWorker(), - } - : undefined, + this.e2eeLivekitOptions(), ); } else { logger.log( @@ -1709,20 +1707,24 @@ export class CallViewModel extends ViewModel { void enterRTCSession( this.matrixRTCSession, localFocus, - this.options.encryptionSystem.kind !== E2eeType.PER_PARTICIPANT, + this.options.encryptionSystem.kind !== E2eeType.NONE, + true, + true, ); }); this.join$.pipe(this.scope.bind()).subscribe(() => { - leaveRTCSession( - this.matrixRTCSession, - "user", // TODO-MULTI-SFU ? - // Wait for the sound in widget mode (it's not long) - Promise.resolve(), // TODO-MULTI-SFU - //Promise.all([audioPromise, posthogRequest]), - ).catch((e) => { - logger.error("Error leaving RTC session", e); - }); + // TODO-MULTI-SFU: this makes no sense what so ever!!! + // need to look into this again. + // leaveRTCSession( + // this.matrixRTCSession, + // "user", // TODO-MULTI-SFU ? + // // Wait for the sound in widget mode (it's not long) + // Promise.resolve(), // TODO-MULTI-SFU + // //Promise.all([audioPromise, posthogRequest]), + // ).catch((e) => { + // logger.error("Error leaving RTC session", e); + // }); }); // Pause upstream of all local media tracks when we're disconnected from