diff --git a/spec/unit/matrixrtc/MatrixRTCSession.spec.ts b/spec/unit/matrixrtc/MatrixRTCSession.spec.ts index d8a718017..7fc4b2f7c 100644 --- a/spec/unit/matrixrtc/MatrixRTCSession.spec.ts +++ b/spec/unit/matrixrtc/MatrixRTCSession.spec.ts @@ -59,6 +59,25 @@ describe("MatrixRTCSession", () => { expect(sess?.callId).toEqual(""); }); + it("ignores memberships where application is not m.call", () => { + const testMembership = Object.assign({}, membershipTemplate, { + application: "not-m.call", + }); + const mockRoom = makeMockRoom([testMembership]); + const sess = MatrixRTCSession.roomSessionForRoom(client, mockRoom); + expect(sess?.memberships).toHaveLength(0); + }); + + it("ignores memberships where callId is not empty", () => { + const testMembership = Object.assign({}, membershipTemplate, { + call_id: "not-empty", + scope: "m.room", + }); + const mockRoom = makeMockRoom([testMembership]); + const sess = MatrixRTCSession.roomSessionForRoom(client, mockRoom); + expect(sess?.memberships).toHaveLength(0); + }); + it("ignores expired memberships events", () => { jest.useFakeTimers(); const expiredMembership = Object.assign({}, membershipTemplate); diff --git a/src/matrixrtc/MatrixRTCSession.ts b/src/matrixrtc/MatrixRTCSession.ts index 15e2ad88c..61340307f 100644 --- a/src/matrixrtc/MatrixRTCSession.ts +++ b/src/matrixrtc/MatrixRTCSession.ts @@ -290,6 +290,12 @@ export class MatrixRTCSession extends TypedEventEmitter< try { const membership = new CallMembership(memberEvent, membershipData); + if (membership.application !== "m.call") { + // Only process MatrixRTC sessions associated with calls + logger.info("Skipping non-call MatrixRTC session"); + continue; + } + if (membership.callId !== "" || membership.scope !== "m.room") { // for now, just ignore anything that isn't a room scope call logger.info(`Ignoring user-scoped call`);