1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-25 05:23:13 +03:00

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
This commit is contained in:
fkwp
2025-08-14 14:44:41 +02:00
committed by GitHub
parent ef080c25f9
commit 6d42ed338e
2 changed files with 25 additions and 0 deletions

View File

@@ -59,6 +59,25 @@ describe("MatrixRTCSession", () => {
expect(sess?.callId).toEqual(""); 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", () => { it("ignores expired memberships events", () => {
jest.useFakeTimers(); jest.useFakeTimers();
const expiredMembership = Object.assign({}, membershipTemplate); const expiredMembership = Object.assign({}, membershipTemplate);

View File

@@ -290,6 +290,12 @@ export class MatrixRTCSession extends TypedEventEmitter<
try { try {
const membership = new CallMembership(memberEvent, membershipData); 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") { if (membership.callId !== "" || membership.scope !== "m.room") {
// for now, just ignore anything that isn't a room scope call // for now, just ignore anything that isn't a room scope call
logger.info(`Ignoring user-scoped call`); logger.info(`Ignoring user-scoped call`);