Skip to content

Commit 0fb35ed

Browse files
committed
Stop sending call notification events
Since I'd like Element Web to stop doing any more inspection than it needs to into the MatrixRTC session state, I suggest we move all responsibility for sending MatrixRTC events to Element Call.
1 parent 42a9ce9 commit 0fb35ed

File tree

2 files changed

+1
-55
lines changed

2 files changed

+1
-55
lines changed

src/models/Call.ts

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@ import { CallType } from "matrix-js-sdk/src/webrtc/call";
2323
import { NamespacedValue } from "matrix-js-sdk/src/NamespacedValue";
2424
import { type IWidgetApiRequest, type ClientWidgetApi, type IWidgetData } from "matrix-widget-api";
2525
import {
26-
MatrixRTCSession,
26+
type MatrixRTCSession,
2727
MatrixRTCSessionEvent,
28-
type CallMembership,
2928
MatrixRTCSessionManagerEvents,
30-
type ICallNotifyContent,
3129
} from "matrix-js-sdk/src/matrixrtc";
3230

3331
import type EventEmitter from "events";
@@ -44,7 +42,6 @@ import ActiveWidgetStore, { ActiveWidgetStoreEvent } from "../stores/ActiveWidge
4442
import { getCurrentLanguage } from "../languageHandler";
4543
import { Anonymity, PosthogAnalytics } from "../PosthogAnalytics";
4644
import { UPDATE_EVENT } from "../stores/AsyncStore";
47-
import { getJoinedNonFunctionalMembers } from "../utils/room/getJoinedNonFunctionalMembers";
4845
import { isVideoRoom } from "../utils/video-rooms";
4946
import { FontWatcher } from "../settings/watchers/FontWatcher";
5047
import { type JitsiCallMemberContent, JitsiCallMemberEventType } from "../call-types";
@@ -858,31 +855,6 @@ export class ElementCall extends Call {
858855
ElementCall.createOrGetCallWidget(room.roomId, room.client, skipLobby, isVideoRoom(room));
859856
}
860857

861-
protected async sendCallNotify(): Promise<void> {
862-
const room = this.room;
863-
const existingOtherRoomCallMembers = MatrixRTCSession.callMembershipsForRoom(room).filter(
864-
// filter all memberships where the application is m.call and the call_id is ""
865-
(m) => {
866-
const isRoomCallMember = m.application === "m.call" && m.callId === "";
867-
const isThisDevice = m.deviceId === this.client.deviceId;
868-
return isRoomCallMember && !isThisDevice;
869-
},
870-
);
871-
872-
const memberCount = getJoinedNonFunctionalMembers(room).length;
873-
if (!isVideoRoom(room) && existingOtherRoomCallMembers.length === 0) {
874-
// send ringing event
875-
const content: ICallNotifyContent = {
876-
"application": "m.call",
877-
"m.mentions": { user_ids: [], room: true },
878-
"notify_type": memberCount == 2 ? "ring" : "notify",
879-
"call_id": "",
880-
};
881-
882-
await room.client.sendEvent(room.roomId, EventType.CallNotify, content);
883-
}
884-
}
885-
886858
protected async performConnection(
887859
audioInput: MediaDeviceInfo | null,
888860
videoInput: MediaDeviceInfo | null,
@@ -912,7 +884,6 @@ export class ElementCall extends Call {
912884
false, // allow user to wait as long as they want (no timeout)
913885
);
914886
}
915-
this.sendCallNotify();
916887
}
917888

918889
protected async performDisconnection(): Promise<void> {

test/unit-tests/models/Call-test.ts

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,31 +1019,6 @@ describe("ElementCall", () => {
10191019
roomSpy.mockRestore();
10201020
addWidgetSpy.mockRestore();
10211021
});
1022-
1023-
it("sends notify event on connect in a room with more than two members", async () => {
1024-
const sendEventSpy = jest.spyOn(room.client, "sendEvent");
1025-
ElementCall.create(room);
1026-
await callConnectProcedure(Call.get(room) as ElementCall);
1027-
expect(sendEventSpy).toHaveBeenCalledWith("!1:example.org", "org.matrix.msc4075.call.notify", {
1028-
"application": "m.call",
1029-
"call_id": "",
1030-
"m.mentions": { room: true, user_ids: [] },
1031-
"notify_type": "notify",
1032-
});
1033-
});
1034-
it("sends ring on create in a DM (two participants) room", async () => {
1035-
setRoomMembers(["@user:example.com", "@user2:example.com"]);
1036-
1037-
const sendEventSpy = jest.spyOn(room.client, "sendEvent");
1038-
ElementCall.create(room);
1039-
await callConnectProcedure(Call.get(room) as ElementCall);
1040-
expect(sendEventSpy).toHaveBeenCalledWith("!1:example.org", "org.matrix.msc4075.call.notify", {
1041-
"application": "m.call",
1042-
"call_id": "",
1043-
"m.mentions": { room: true, user_ids: [] },
1044-
"notify_type": "ring",
1045-
});
1046-
});
10471022
});
10481023

10491024
describe("instance in a video room", () => {

0 commit comments

Comments
 (0)