diff --git a/src/RoomNotifs.ts b/src/RoomNotifs.ts index 39d1d5d4aa..97e4785104 100644 --- a/src/RoomNotifs.ts +++ b/src/RoomNotifs.ts @@ -17,7 +17,13 @@ limitations under the License. import { PushProcessor } from 'matrix-js-sdk/src/pushprocessor'; import { NotificationCountType, Room } from "matrix-js-sdk/src/models/room"; -import { ConditionKind, IPushRule, PushRuleActionName, PushRuleKind } from "matrix-js-sdk/src/@types/PushRules"; +import { + ConditionKind, + IPushRule, + PushRuleActionName, + PushRuleKind, + TweakName, +} from "matrix-js-sdk/src/@types/PushRules"; import { EventType } from 'matrix-js-sdk/src/@types/event'; import { MatrixClientPeg } from './MatrixClientPeg'; @@ -144,13 +150,13 @@ function setRoomNotifsStateMuted(roomId: string): Promise { promises.push(cli.addPushRule('global', PushRuleKind.Override, roomId, { conditions: [ { - kind: 'event_match', + kind: ConditionKind.EventMatch, key: 'room_id', pattern: roomId, }, ], actions: [ - 'dont_notify', + PushRuleActionName.DontNotify, ], })); @@ -174,7 +180,7 @@ function setRoomNotifsStateUnmuted(roomId: string, newState: RoomNotifState): Pr } else if (newState === RoomNotifState.MentionsOnly) { promises.push(cli.addPushRule('global', PushRuleKind.RoomSpecific, roomId, { actions: [ - 'dont_notify', + PushRuleActionName.DontNotify, ], })); // https://matrix.org/jira/browse/SPEC-400 @@ -182,9 +188,9 @@ function setRoomNotifsStateUnmuted(roomId: string, newState: RoomNotifState): Pr } else if (newState === RoomNotifState.AllMessagesLoud) { promises.push(cli.addPushRule('global', PushRuleKind.RoomSpecific, roomId, { actions: [ - 'notify', + PushRuleActionName.Notify, { - set_tweak: 'sound', + set_tweak: TweakName.Sound, value: 'default', }, ], diff --git a/test/RoomNotifs-test.ts b/test/RoomNotifs-test.ts index 703f681e32..3f486205df 100644 --- a/test/RoomNotifs-test.ts +++ b/test/RoomNotifs-test.ts @@ -79,7 +79,7 @@ describe("RoomNotifs test", () => { rule_id: "!roomId:server", enabled: true, default: false, - actions: [{ set_tweak: TweakName.Sound }], + actions: [{ set_tweak: TweakName.Sound, value: "default" }], }); expect(getRoomNotifsState("!roomId:server")).toBe(RoomNotifState.AllMessagesLoud); });