Consider the empty push rule actions array equiv to deprecated dont_notify (#11155)
* Consider the empty push rule actions array equiv to deprecated dont_notify * Switch primary tests to empty actions, add test for dont_notify * strict types
This commit is contained in:
parent
6836a5fa7b
commit
209f5bdf33
3 changed files with 12 additions and 3 deletions
|
@ -219,7 +219,10 @@ function isRuleRoomMuteRuleForRoomId(roomId: string, rule: IPushRule): boolean {
|
||||||
}
|
}
|
||||||
|
|
||||||
function isMuteRule(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(
|
export function determineUnreadState(
|
||||||
|
|
|
@ -64,6 +64,13 @@ describe("RoomNotifs test", () => {
|
||||||
expect(getRoomNotifsState(client, room.roomId)).toBe(RoomNotifState.Mute);
|
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", () => {
|
it("getRoomNotifsState handles mentions only", () => {
|
||||||
(client as any).getRoomPushRule = () => ({
|
(client as any).getRoomPushRule = () => ({
|
||||||
rule_id: "!roomId:server",
|
rule_id: "!roomId:server",
|
||||||
|
|
|
@ -34,7 +34,6 @@ import {
|
||||||
RoomType,
|
RoomType,
|
||||||
KNOWN_SAFE_ROOM_VERSION,
|
KNOWN_SAFE_ROOM_VERSION,
|
||||||
ConditionKind,
|
ConditionKind,
|
||||||
PushRuleActionName,
|
|
||||||
IPushRules,
|
IPushRules,
|
||||||
RelationType,
|
RelationType,
|
||||||
} from "matrix-js-sdk/src/matrix";
|
} from "matrix-js-sdk/src/matrix";
|
||||||
|
@ -796,7 +795,7 @@ export function muteRoom(room: Room): void {
|
||||||
pattern: room.roomId,
|
pattern: room.roomId,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
actions: [PushRuleActionName.DontNotify],
|
actions: [],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue