Skip to content

Commit 6d42ed3

Browse files
authored
Only process MatrixRTC sessions associated with calls for callMembershipsForRoom (#4960)
* Only process MatrixRTC sessions associated with calls * tests: Only process MatrixRTC sessions associated with calls * linting
1 parent ef080c2 commit 6d42ed3

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

spec/unit/matrixrtc/MatrixRTCSession.spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,25 @@ describe("MatrixRTCSession", () => {
5959
expect(sess?.callId).toEqual("");
6060
});
6161

62+
it("ignores memberships where application is not m.call", () => {
63+
const testMembership = Object.assign({}, membershipTemplate, {
64+
application: "not-m.call",
65+
});
66+
const mockRoom = makeMockRoom([testMembership]);
67+
const sess = MatrixRTCSession.roomSessionForRoom(client, mockRoom);
68+
expect(sess?.memberships).toHaveLength(0);
69+
});
70+
71+
it("ignores memberships where callId is not empty", () => {
72+
const testMembership = Object.assign({}, membershipTemplate, {
73+
call_id: "not-empty",
74+
scope: "m.room",
75+
});
76+
const mockRoom = makeMockRoom([testMembership]);
77+
const sess = MatrixRTCSession.roomSessionForRoom(client, mockRoom);
78+
expect(sess?.memberships).toHaveLength(0);
79+
});
80+
6281
it("ignores expired memberships events", () => {
6382
jest.useFakeTimers();
6483
const expiredMembership = Object.assign({}, membershipTemplate);

src/matrixrtc/MatrixRTCSession.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,12 @@ export class MatrixRTCSession extends TypedEventEmitter<
290290
try {
291291
const membership = new CallMembership(memberEvent, membershipData);
292292

293+
if (membership.application !== "m.call") {
294+
// Only process MatrixRTC sessions associated with calls
295+
logger.info("Skipping non-call MatrixRTC session");
296+
continue;
297+
}
298+
293299
if (membership.callId !== "" || membership.scope !== "m.room") {
294300
// for now, just ignore anything that isn't a room scope call
295301
logger.info(`Ignoring user-scoped call`);

0 commit comments

Comments
 (0)