diff --git a/src/RoomNotifs.ts b/src/RoomNotifs.ts index c484d68f18..c1f94cd71c 100644 --- a/src/RoomNotifs.ts +++ b/src/RoomNotifs.ts @@ -219,7 +219,10 @@ function isRuleRoomMuteRuleForRoomId(roomId: string, rule: IPushRule): boolean { } function isMuteRule(rule: IPushRule): boolean { - return rule.actions.length === 1 && rule.actions[0] === PushRuleActionName.DontNotify; + // DontNotify is equivalent to the empty actions array + return ( + rule.actions.length === 0 || (rule.actions.length === 1 && rule.actions[0] === PushRuleActionName.DontNotify) + ); } export function determineUnreadState( diff --git a/test/RoomNotifs-test.ts b/test/RoomNotifs-test.ts index e80e943e3c..505de622bc 100644 --- a/test/RoomNotifs-test.ts +++ b/test/RoomNotifs-test.ts @@ -64,6 +64,13 @@ describe("RoomNotifs test", () => { expect(getRoomNotifsState(client, room.roomId)).toBe(RoomNotifState.Mute); }); + it("getRoomNotifsState handles mute state for legacy DontNotify action", () => { + const room = mkRoom(client, "!roomId:server"); + muteRoom(room); + client.pushRules!.global.override![0]!.actions = [PushRuleActionName.DontNotify]; + expect(getRoomNotifsState(client, room.roomId)).toBe(RoomNotifState.Mute); + }); + it("getRoomNotifsState handles mentions only", () => { (client as any).getRoomPushRule = () => ({ rule_id: "!roomId:server", diff --git a/test/test-utils/test-utils.ts b/test/test-utils/test-utils.ts index 1e2fe78ca1..b4de68df35 100644 --- a/test/test-utils/test-utils.ts +++ b/test/test-utils/test-utils.ts @@ -34,7 +34,6 @@ import { RoomType, KNOWN_SAFE_ROOM_VERSION, ConditionKind, - PushRuleActionName, IPushRules, RelationType, } from "matrix-js-sdk/src/matrix"; @@ -796,7 +795,7 @@ export function muteRoom(room: Room): void { pattern: room.roomId, }, ], - actions: [PushRuleActionName.DontNotify], + actions: [], }, ]; }