diff --git a/spec/unit/matrixrtc/MatrixRTCSession.spec.ts b/spec/unit/matrixrtc/MatrixRTCSession.spec.ts index d0ca37b2d85..2b391661433 100644 --- a/spec/unit/matrixrtc/MatrixRTCSession.spec.ts +++ b/spec/unit/matrixrtc/MatrixRTCSession.spec.ts @@ -399,6 +399,42 @@ describe("MatrixRTCSession", () => { jest.useRealTimers(); }); + describe("non-legacy calls", () => { + const activeFocusConfig = { type: "livekit", livekit_service_url: "https://active.url" }; + const activeFocus = { type: "livekit", focus_selection: "oldest_membership" }; + + function testJoin(useOwnedStateEvents: boolean): void { + if (useOwnedStateEvents) { + mockRoom.getVersion = jest.fn().mockReturnValue("org.matrix.msc3779.default"); + } + + jest.useFakeTimers(); + sess!.joinRoomSession([activeFocusConfig], activeFocus, { useLegacyMemberEvents: false }); + expect(client.sendStateEvent).toHaveBeenCalledWith( + mockRoom!.roomId, + EventType.GroupCallMemberPrefix, + { + application: "m.call", + scope: "m.room", + call_id: "", + device_id: "AAAAAAA", + foci_preferred: [activeFocusConfig], + focus_active: activeFocus, + } satisfies SessionMembershipData, + `${!useOwnedStateEvents ? "_" : ""}@alice:example.org_AAAAAAA`, + ); + jest.useRealTimers(); + } + + it("sends a membership event with session payload when joining a non-legacy call", () => { + testJoin(false); + }); + + it("does not prefix the state key with _ for rooms that support user-owned state events", () => { + testJoin(true); + }); + }); + it("does nothing if join called when already joined", () => { sess!.joinRoomSession([mockFocus], mockFocus); diff --git a/spec/unit/matrixrtc/mocks.ts b/spec/unit/matrixrtc/mocks.ts index 7d63b32b79a..c11544a0e9e 100644 --- a/spec/unit/matrixrtc/mocks.ts +++ b/spec/unit/matrixrtc/mocks.ts @@ -30,6 +30,7 @@ export function makeMockRoom(membershipData: MembershipData, localAge: number | getLiveTimeline: jest.fn().mockReturnValue({ getState: jest.fn().mockReturnValue(roomState), }), + getVersion: jest.fn().mockReturnValue("default"), } as unknown as Room; } diff --git a/src/matrixrtc/MatrixRTCSession.ts b/src/matrixrtc/MatrixRTCSession.ts index 2f06eba633a..cc155fd3e6a 100644 --- a/src/matrixrtc/MatrixRTCSession.ts +++ b/src/matrixrtc/MatrixRTCSession.ts @@ -869,7 +869,7 @@ export class MatrixRTCSession extends TypedEventEmitter { if (!this.manageMediaKeys) return;