You've already forked matrix-js-sdk
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:
@@ -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);
|
||||||
|
|||||||
@@ -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`);
|
||||||
|
|||||||
Reference in New Issue
Block a user