From 75dbc943cf19ab63327833ee2247dcc5f4937403 Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Thu, 11 Sep 2025 08:26:29 +0100 Subject: [PATCH] =?UTF-8?q?Revert=20"Stop=20ringing=20and=20remove=20toast?= =?UTF-8?q?=20if=20another=20device=20answers=20a=20RTC=20call.=20(?= =?UTF-8?q?=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit a73f4f5803b315e4e4890c5ed5f2afa4906539f8. --- src/Notifier.ts | 16 +---------- test/unit-tests/Notifier-test.ts | 47 -------------------------------- 2 files changed, 1 insertion(+), 62 deletions(-) diff --git a/src/Notifier.ts b/src/Notifier.ts index dd47b8b204..7dce26d6bd 100644 --- a/src/Notifier.ts +++ b/src/Notifier.ts @@ -486,27 +486,13 @@ class NotifierClass extends TypedEventEmitter m.sender === cli.getUserId()); - if (EventType.GroupCallMemberPrefix === type && thisUserHasConnectedDevice) { - const content = ev.getContent(); - - if (typeof content.call_id !== "string") { - logger.warn( - "Received malformatted GroupCallMemberPrefix event. Did not contain 'call_id' of type 'string'", - ); - return; - } - // One of our devices has joined the call, so dismiss it. - ToastStore.sharedInstance().dismissToast(getIncomingCallToastKey(content.call_id, room.roomId)); - } // Check maximum age (<= 15 seconds) of a call notify event that will trigger a ringing notification - else if (EventType.CallNotify === type && (ev.getAge() ?? 0) < 15000 && !thisUserHasConnectedDevice) { + if (EventType.CallNotify === ev.getType() && (ev.getAge() ?? 0) < 15000 && !thisUserHasConnectedDevice) { const content = ev.getContent(); const roomId = ev.getRoomId(); - if (typeof content.call_id !== "string") { logger.warn("Received malformatted CallNotify event. Did not contain 'call_id' of type 'string'"); return; diff --git a/test/unit-tests/Notifier-test.ts b/test/unit-tests/Notifier-test.ts index e5b8f84f51..92df3bc385 100644 --- a/test/unit-tests/Notifier-test.ts +++ b/test/unit-tests/Notifier-test.ts @@ -371,7 +371,6 @@ describe("Notifier", () => { beforeEach(() => { jest.spyOn(SettingsStore, "getValue").mockReturnValue(true); jest.spyOn(ToastStore.sharedInstance(), "addOrReplaceToast"); - jest.spyOn(ToastStore.sharedInstance(), "dismissToast"); mockClient.getPushActionsForEvent.mockReturnValue({ notify: true, @@ -444,52 +443,6 @@ describe("Notifier", () => { spyCallMemberships.mockRestore(); }); - it("dismisses call notification when another device answers the call", () => { - const notifyEvent = emitCallNotifyEvent(); - const spyCallMemberships = jest.spyOn(MatrixRTCSession, "callMembershipsForRoom"); - - expect(ToastStore.sharedInstance().addOrReplaceToast).toHaveBeenCalledWith( - expect.objectContaining({ - key: getIncomingCallToastKey(notifyEvent.getContent().call_id ?? "", roomId), - priority: 100, - component: IncomingCallToast, - bodyClassName: "mx_IncomingCallToast", - props: { notifyEvent }, - }), - ); - // Mock ourselves joining the call. - spyCallMemberships.mockReturnValue([ - new CallMembership( - mkEvent({ - event: true, - room: testRoom.roomId, - user: userId, - type: EventType.GroupCallMemberPrefix, - content: {}, - }), - { - call_id: "123", - application: "m.call", - focus_active: { type: "livekit" }, - foci_preferred: [], - device_id: "DEVICE", - }, - ), - ]); - const callEvent = mkEvent({ - type: EventType.GroupCallMemberPrefix, - user: "@alice:foo", - room: roomId, - content: { - call_id: "abc123", - }, - event: true, - }); - emitLiveEvent(callEvent); - expect(ToastStore.sharedInstance().dismissToast).toHaveBeenCalled(); - spyCallMemberships.mockRestore(); - }); - it("should not show toast when calling with non-group call event", () => { emitCallNotifyEvent("event_type");