Implement new model, hooks and reconcilation code for new GYU notification settings (#11089)
* Define new notification settings model * Add new hooks * make ts-strict happy * add unit tests * chore: make eslint/prettier happier :) * make ts-strict happier * Update src/notifications/NotificationUtils.ts Co-authored-by: Robin <robin@robin.town> * Add tests for hooks * chore: fixed lint issues * Add comments --------- Co-authored-by: Robin <robin@robin.town>
This commit is contained in:
parent
2972219959
commit
97765613bc
15 changed files with 2383 additions and 6 deletions
160
test/models/notificationsettings/NotificationSettings-test.ts
Normal file
160
test/models/notificationsettings/NotificationSettings-test.ts
Normal file
|
@ -0,0 +1,160 @@
|
|||
/*
|
||||
Copyright 2023 The Matrix.org Foundation C.I.C.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { IPushRules, PushRuleKind, RuleId } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import {
|
||||
DefaultNotificationSettings,
|
||||
NotificationSettings,
|
||||
} from "../../../src/models/notificationsettings/NotificationSettings";
|
||||
import { reconcileNotificationSettings } from "../../../src/models/notificationsettings/reconcileNotificationSettings";
|
||||
import { toNotificationSettings } from "../../../src/models/notificationsettings/toNotificationSettings";
|
||||
import { StandardActions } from "../../../src/notifications/StandardActions";
|
||||
import { RoomNotifState } from "../../../src/RoomNotifs";
|
||||
|
||||
describe("NotificationSettings", () => {
|
||||
it("parses a typical pushrules setup correctly", async () => {
|
||||
const pushRules = (await import("./pushrules_sample.json")) as IPushRules;
|
||||
const model = toNotificationSettings(pushRules, false);
|
||||
const pendingChanges = reconcileNotificationSettings(pushRules, model, false);
|
||||
const expectedModel: NotificationSettings = {
|
||||
globalMute: false,
|
||||
defaultLevels: {
|
||||
dm: RoomNotifState.AllMessages,
|
||||
room: RoomNotifState.MentionsOnly,
|
||||
},
|
||||
sound: {
|
||||
calls: "ring",
|
||||
mentions: "default",
|
||||
people: undefined,
|
||||
},
|
||||
activity: {
|
||||
bot_notices: false,
|
||||
invite: true,
|
||||
status_event: false,
|
||||
},
|
||||
mentions: {
|
||||
user: true,
|
||||
room: true,
|
||||
keywords: true,
|
||||
},
|
||||
keywords: ["justjann3", "justj4nn3", "justj4nne", "Janne", "J4nne", "Jann3", "jann3", "j4nne", "janne"],
|
||||
};
|
||||
expect(model).toEqual(expectedModel);
|
||||
expect(pendingChanges.added).toHaveLength(0);
|
||||
expect(pendingChanges.deleted).toHaveLength(0);
|
||||
expect(pendingChanges.updated).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("generates correct mutations for a changed model", async () => {
|
||||
const pushRules = (await import("./pushrules_sample.json")) as IPushRules;
|
||||
const pendingChanges = reconcileNotificationSettings(pushRules, DefaultNotificationSettings, false);
|
||||
expect(pendingChanges.added).toHaveLength(0);
|
||||
expect(pendingChanges.deleted).toEqual([
|
||||
{ kind: PushRuleKind.ContentSpecific, rule_id: "justjann3" },
|
||||
{ kind: PushRuleKind.ContentSpecific, rule_id: "justj4nn3" },
|
||||
{ kind: PushRuleKind.ContentSpecific, rule_id: "justj4nne" },
|
||||
{ kind: PushRuleKind.ContentSpecific, rule_id: "Janne" },
|
||||
{ kind: PushRuleKind.ContentSpecific, rule_id: "J4nne" },
|
||||
{ kind: PushRuleKind.ContentSpecific, rule_id: "Jann3" },
|
||||
{ kind: PushRuleKind.ContentSpecific, rule_id: "jann3" },
|
||||
{ kind: PushRuleKind.ContentSpecific, rule_id: "j4nne" },
|
||||
{ kind: PushRuleKind.ContentSpecific, rule_id: "janne" },
|
||||
]);
|
||||
expect(pendingChanges.updated).toEqual([
|
||||
{
|
||||
kind: PushRuleKind.Underride,
|
||||
rule_id: RuleId.EncryptedMessage,
|
||||
enabled: true,
|
||||
actions: StandardActions.ACTION_NOTIFY,
|
||||
},
|
||||
{
|
||||
kind: PushRuleKind.Underride,
|
||||
rule_id: RuleId.Message,
|
||||
enabled: true,
|
||||
actions: StandardActions.ACTION_NOTIFY,
|
||||
},
|
||||
{
|
||||
kind: PushRuleKind.Underride,
|
||||
rule_id: RuleId.EncryptedDM,
|
||||
enabled: true,
|
||||
actions: StandardActions.ACTION_NOTIFY_DEFAULT_SOUND,
|
||||
},
|
||||
{
|
||||
kind: PushRuleKind.Underride,
|
||||
rule_id: RuleId.DM,
|
||||
enabled: true,
|
||||
actions: StandardActions.ACTION_NOTIFY_DEFAULT_SOUND,
|
||||
},
|
||||
{
|
||||
kind: PushRuleKind.Override,
|
||||
rule_id: RuleId.SuppressNotices,
|
||||
enabled: false,
|
||||
actions: StandardActions.ACTION_DONT_NOTIFY,
|
||||
},
|
||||
{
|
||||
kind: PushRuleKind.Override,
|
||||
rule_id: RuleId.InviteToSelf,
|
||||
enabled: true,
|
||||
actions: StandardActions.ACTION_NOTIFY_DEFAULT_SOUND,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("correctly migrates old settings to the new model", async () => {
|
||||
const pushRules = (await import("./pushrules_default.json")) as IPushRules;
|
||||
const newPushRules = (await import("./pushrules_default_new.json")) as IPushRules;
|
||||
const model = toNotificationSettings(pushRules, false);
|
||||
const expectedModel: NotificationSettings = {
|
||||
globalMute: false,
|
||||
defaultLevels: {
|
||||
dm: RoomNotifState.AllMessages,
|
||||
room: RoomNotifState.MentionsOnly,
|
||||
},
|
||||
sound: {
|
||||
calls: "ring",
|
||||
mentions: "default",
|
||||
people: "default",
|
||||
},
|
||||
activity: {
|
||||
bot_notices: false,
|
||||
invite: true,
|
||||
status_event: true,
|
||||
},
|
||||
mentions: {
|
||||
user: true,
|
||||
room: true,
|
||||
keywords: true,
|
||||
},
|
||||
keywords: [],
|
||||
};
|
||||
expect(model).toEqual(expectedModel);
|
||||
const pendingChanges = reconcileNotificationSettings(pushRules, model, false);
|
||||
expect(pendingChanges.added).toHaveLength(0);
|
||||
expect(pendingChanges.updated).toEqual([
|
||||
{
|
||||
kind: PushRuleKind.Override,
|
||||
rule_id: RuleId.MemberEvent,
|
||||
enabled: true,
|
||||
actions: StandardActions.ACTION_NOTIFY,
|
||||
},
|
||||
]);
|
||||
const roundtripPendingChanges = reconcileNotificationSettings(newPushRules, model, false);
|
||||
expect(roundtripPendingChanges.added).toHaveLength(0);
|
||||
expect(roundtripPendingChanges.deleted).toHaveLength(0);
|
||||
expect(roundtripPendingChanges.updated).toHaveLength(0);
|
||||
});
|
||||
});
|
423
test/models/notificationsettings/pushrules_default.json
Normal file
423
test/models/notificationsettings/pushrules_default.json
Normal file
|
@ -0,0 +1,423 @@
|
|||
{
|
||||
"global": {
|
||||
"underride": [
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "m.call.invite"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "sound",
|
||||
"value": "ring"
|
||||
},
|
||||
{
|
||||
"set_tweak": "highlight",
|
||||
"value": false
|
||||
}
|
||||
],
|
||||
"rule_id": ".m.rule.call",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "underride"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "m.room.message"
|
||||
},
|
||||
{
|
||||
"kind": "room_member_count",
|
||||
"is": "2"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "sound",
|
||||
"value": "default"
|
||||
},
|
||||
{
|
||||
"set_tweak": "highlight",
|
||||
"value": false
|
||||
}
|
||||
],
|
||||
"rule_id": ".m.rule.room_one_to_one",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "underride"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "m.room.encrypted"
|
||||
},
|
||||
{
|
||||
"kind": "room_member_count",
|
||||
"is": "2"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "sound",
|
||||
"value": "default"
|
||||
},
|
||||
{
|
||||
"set_tweak": "highlight",
|
||||
"value": false
|
||||
}
|
||||
],
|
||||
"rule_id": ".m.rule.encrypted_room_one_to_one",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "underride"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "m.room.message"
|
||||
}
|
||||
],
|
||||
"actions": ["dont_notify"],
|
||||
"rule_id": ".m.rule.message",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "underride"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "m.room.encrypted"
|
||||
}
|
||||
],
|
||||
"actions": ["dont_notify"],
|
||||
"rule_id": ".m.rule.encrypted",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "underride"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "im.vector.modular.widgets"
|
||||
},
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "content.type",
|
||||
"pattern": "jitsi"
|
||||
},
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "state_key",
|
||||
"pattern": "*"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "highlight",
|
||||
"value": false
|
||||
}
|
||||
],
|
||||
"rule_id": ".im.vector.jitsi",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "underride"
|
||||
},
|
||||
{
|
||||
"rule_id": ".org.matrix.msc3914.rule.room.call",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "org.matrix.msc3401.call"
|
||||
},
|
||||
{
|
||||
"kind": "call_started"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "sound",
|
||||
"value": "default"
|
||||
}
|
||||
],
|
||||
"kind": "underride"
|
||||
}
|
||||
],
|
||||
"sender": [],
|
||||
"room": [],
|
||||
"content": [
|
||||
{
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "highlight"
|
||||
},
|
||||
{
|
||||
"set_tweak": "sound",
|
||||
"value": "default"
|
||||
}
|
||||
],
|
||||
"rule_id": ".m.rule.contains_user_name",
|
||||
"default": true,
|
||||
"pattern": "jannetestuser",
|
||||
"enabled": true,
|
||||
"kind": "content"
|
||||
}
|
||||
],
|
||||
"override": [
|
||||
{
|
||||
"conditions": [],
|
||||
"actions": ["dont_notify"],
|
||||
"rule_id": ".m.rule.master",
|
||||
"default": true,
|
||||
"enabled": false,
|
||||
"kind": "override"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "content.msgtype",
|
||||
"pattern": "m.notice"
|
||||
}
|
||||
],
|
||||
"actions": ["dont_notify"],
|
||||
"rule_id": ".m.rule.suppress_notices",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "override"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "m.room.member"
|
||||
},
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "content.membership",
|
||||
"pattern": "invite"
|
||||
},
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "state_key",
|
||||
"pattern": "@jannetestuser:beta.matrix.org"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "highlight",
|
||||
"value": false
|
||||
},
|
||||
{
|
||||
"set_tweak": "sound",
|
||||
"value": "default"
|
||||
}
|
||||
],
|
||||
"rule_id": ".m.rule.invite_for_me",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "override"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "m.room.member"
|
||||
}
|
||||
],
|
||||
"actions": ["dont_notify"],
|
||||
"rule_id": ".m.rule.member_event",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "override"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_property_contains",
|
||||
"key": "content.org\\.matrix\\.msc3952\\.mentions.user_ids",
|
||||
"value": "@jannetestuser:beta.matrix.org"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "highlight"
|
||||
}
|
||||
],
|
||||
"rule_id": ".org.matrix.msc3952.is_user_mention",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "override"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "contains_display_name"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "highlight"
|
||||
},
|
||||
{
|
||||
"set_tweak": "sound",
|
||||
"value": "default"
|
||||
}
|
||||
],
|
||||
"rule_id": ".m.rule.contains_display_name",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "override"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_property_is",
|
||||
"key": "content.org\\.matrix\\.msc3952\\.mentions.room",
|
||||
"value": true
|
||||
},
|
||||
{
|
||||
"kind": "sender_notification_permission",
|
||||
"key": "room"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "highlight"
|
||||
}
|
||||
],
|
||||
"rule_id": ".org.matrix.msc3952.is_room_mention",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "override"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "sender_notification_permission",
|
||||
"key": "room"
|
||||
},
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "content.body",
|
||||
"pattern": "@room"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "highlight",
|
||||
"value": false
|
||||
}
|
||||
],
|
||||
"rule_id": ".m.rule.roomnotif",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "override"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "m.room.tombstone"
|
||||
},
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "state_key",
|
||||
"pattern": ""
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "highlight"
|
||||
}
|
||||
],
|
||||
"rule_id": ".m.rule.tombstone",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "override"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "m.reaction"
|
||||
}
|
||||
],
|
||||
"actions": ["dont_notify"],
|
||||
"rule_id": ".m.rule.reaction",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "override"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "m.room.server_acl"
|
||||
},
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "state_key",
|
||||
"pattern": ""
|
||||
}
|
||||
],
|
||||
"actions": [],
|
||||
"rule_id": ".m.rule.room.server_acl",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "override"
|
||||
},
|
||||
{
|
||||
"rule_id": ".org.matrix.msc3786.rule.room.server_acl",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "m.room.server_acl"
|
||||
},
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "state_key",
|
||||
"pattern": ""
|
||||
}
|
||||
],
|
||||
"actions": [],
|
||||
"kind": "override"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
429
test/models/notificationsettings/pushrules_default_new.json
Normal file
429
test/models/notificationsettings/pushrules_default_new.json
Normal file
|
@ -0,0 +1,429 @@
|
|||
{
|
||||
"global": {
|
||||
"underride": [
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "m.call.invite"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "sound",
|
||||
"value": "ring"
|
||||
},
|
||||
{
|
||||
"set_tweak": "highlight",
|
||||
"value": false
|
||||
}
|
||||
],
|
||||
"rule_id": ".m.rule.call",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "underride"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "m.room.message"
|
||||
},
|
||||
{
|
||||
"kind": "room_member_count",
|
||||
"is": "2"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "sound",
|
||||
"value": "default"
|
||||
},
|
||||
{
|
||||
"set_tweak": "highlight",
|
||||
"value": false
|
||||
}
|
||||
],
|
||||
"rule_id": ".m.rule.room_one_to_one",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "underride"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "m.room.encrypted"
|
||||
},
|
||||
{
|
||||
"kind": "room_member_count",
|
||||
"is": "2"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "sound",
|
||||
"value": "default"
|
||||
},
|
||||
{
|
||||
"set_tweak": "highlight",
|
||||
"value": false
|
||||
}
|
||||
],
|
||||
"rule_id": ".m.rule.encrypted_room_one_to_one",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "underride"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "m.room.message"
|
||||
}
|
||||
],
|
||||
"actions": ["dont_notify"],
|
||||
"rule_id": ".m.rule.message",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "underride"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "m.room.encrypted"
|
||||
}
|
||||
],
|
||||
"actions": ["dont_notify"],
|
||||
"rule_id": ".m.rule.encrypted",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "underride"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "im.vector.modular.widgets"
|
||||
},
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "content.type",
|
||||
"pattern": "jitsi"
|
||||
},
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "state_key",
|
||||
"pattern": "*"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "highlight",
|
||||
"value": false
|
||||
}
|
||||
],
|
||||
"rule_id": ".im.vector.jitsi",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "underride"
|
||||
},
|
||||
{
|
||||
"rule_id": ".org.matrix.msc3914.rule.room.call",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "org.matrix.msc3401.call"
|
||||
},
|
||||
{
|
||||
"kind": "call_started"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "sound",
|
||||
"value": "default"
|
||||
}
|
||||
],
|
||||
"kind": "underride"
|
||||
}
|
||||
],
|
||||
"sender": [],
|
||||
"room": [],
|
||||
"content": [
|
||||
{
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "highlight"
|
||||
},
|
||||
{
|
||||
"set_tweak": "sound",
|
||||
"value": "default"
|
||||
}
|
||||
],
|
||||
"rule_id": ".m.rule.contains_user_name",
|
||||
"default": true,
|
||||
"pattern": "jannetestuser",
|
||||
"enabled": true,
|
||||
"kind": "content"
|
||||
}
|
||||
],
|
||||
"override": [
|
||||
{
|
||||
"conditions": [],
|
||||
"actions": ["dont_notify"],
|
||||
"rule_id": ".m.rule.master",
|
||||
"default": true,
|
||||
"enabled": false,
|
||||
"kind": "override"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "content.msgtype",
|
||||
"pattern": "m.notice"
|
||||
}
|
||||
],
|
||||
"actions": ["dont_notify"],
|
||||
"rule_id": ".m.rule.suppress_notices",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "override"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "m.room.member"
|
||||
},
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "content.membership",
|
||||
"pattern": "invite"
|
||||
},
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "state_key",
|
||||
"pattern": "@jannetestuser:beta.matrix.org"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "sound",
|
||||
"value": "default"
|
||||
},
|
||||
{
|
||||
"set_tweak": "highlight",
|
||||
"value": false
|
||||
}
|
||||
],
|
||||
"rule_id": ".m.rule.invite_for_me",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "override"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "m.room.member"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "highlight",
|
||||
"value": false
|
||||
}
|
||||
],
|
||||
"rule_id": ".m.rule.member_event",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "override"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_property_contains",
|
||||
"key": "content.org\\.matrix\\.msc3952\\.mentions.user_ids",
|
||||
"value": "@jannetestuser:beta.matrix.org"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "highlight"
|
||||
}
|
||||
],
|
||||
"rule_id": ".org.matrix.msc3952.is_user_mention",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "override"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "contains_display_name"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "highlight"
|
||||
},
|
||||
{
|
||||
"set_tweak": "sound",
|
||||
"value": "default"
|
||||
}
|
||||
],
|
||||
"rule_id": ".m.rule.contains_display_name",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "override"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_property_is",
|
||||
"key": "content.org\\.matrix\\.msc3952\\.mentions.room",
|
||||
"value": true
|
||||
},
|
||||
{
|
||||
"kind": "sender_notification_permission",
|
||||
"key": "room"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "highlight"
|
||||
}
|
||||
],
|
||||
"rule_id": ".org.matrix.msc3952.is_room_mention",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "override"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "sender_notification_permission",
|
||||
"key": "room"
|
||||
},
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "content.body",
|
||||
"pattern": "@room"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "highlight",
|
||||
"value": false
|
||||
}
|
||||
],
|
||||
"rule_id": ".m.rule.roomnotif",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "override"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "m.room.tombstone"
|
||||
},
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "state_key",
|
||||
"pattern": ""
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "highlight"
|
||||
}
|
||||
],
|
||||
"rule_id": ".m.rule.tombstone",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "override"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "m.reaction"
|
||||
}
|
||||
],
|
||||
"actions": ["dont_notify"],
|
||||
"rule_id": ".m.rule.reaction",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "override"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "m.room.server_acl"
|
||||
},
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "state_key",
|
||||
"pattern": ""
|
||||
}
|
||||
],
|
||||
"actions": [],
|
||||
"rule_id": ".m.rule.room.server_acl",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "override"
|
||||
},
|
||||
{
|
||||
"rule_id": ".org.matrix.msc3786.rule.room.server_acl",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "m.room.server_acl"
|
||||
},
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "state_key",
|
||||
"pattern": ""
|
||||
}
|
||||
],
|
||||
"actions": [],
|
||||
"kind": "override"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
566
test/models/notificationsettings/pushrules_sample.json
Normal file
566
test/models/notificationsettings/pushrules_sample.json
Normal file
|
@ -0,0 +1,566 @@
|
|||
{
|
||||
"global": {
|
||||
"underride": [
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "m.call.invite"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "sound",
|
||||
"value": "ring"
|
||||
},
|
||||
{
|
||||
"set_tweak": "highlight",
|
||||
"value": false
|
||||
}
|
||||
],
|
||||
"rule_id": ".m.rule.call",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "underride"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "m.room.message"
|
||||
},
|
||||
{
|
||||
"kind": "room_member_count",
|
||||
"is": "2"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "highlight",
|
||||
"value": false
|
||||
}
|
||||
],
|
||||
"rule_id": ".m.rule.room_one_to_one",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "underride"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "m.room.encrypted"
|
||||
},
|
||||
{
|
||||
"kind": "room_member_count",
|
||||
"is": "2"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "highlight",
|
||||
"value": false
|
||||
}
|
||||
],
|
||||
"rule_id": ".m.rule.encrypted_room_one_to_one",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "underride"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "m.room.message"
|
||||
}
|
||||
],
|
||||
"actions": ["dont_notify"],
|
||||
"rule_id": ".m.rule.message",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "underride"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "m.room.encrypted"
|
||||
}
|
||||
],
|
||||
"actions": ["dont_notify"],
|
||||
"rule_id": ".m.rule.encrypted",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "underride"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "im.vector.modular.widgets"
|
||||
},
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "content.type",
|
||||
"pattern": "jitsi"
|
||||
},
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "state_key",
|
||||
"pattern": "*"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "highlight",
|
||||
"value": false
|
||||
}
|
||||
],
|
||||
"rule_id": ".im.vector.jitsi",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "underride"
|
||||
},
|
||||
{
|
||||
"rule_id": ".org.matrix.msc3914.rule.room.call",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "org.matrix.msc3401.call"
|
||||
},
|
||||
{
|
||||
"kind": "call_started"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "sound",
|
||||
"value": "default"
|
||||
}
|
||||
],
|
||||
"kind": "underride"
|
||||
}
|
||||
],
|
||||
"sender": [],
|
||||
"room": [],
|
||||
"content": [
|
||||
{
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "sound",
|
||||
"value": "default"
|
||||
},
|
||||
{
|
||||
"set_tweak": "highlight"
|
||||
}
|
||||
],
|
||||
"pattern": "justjann3",
|
||||
"rule_id": "justjann3",
|
||||
"default": false,
|
||||
"enabled": true,
|
||||
"kind": "content"
|
||||
},
|
||||
{
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "sound",
|
||||
"value": "default"
|
||||
},
|
||||
{
|
||||
"set_tweak": "highlight"
|
||||
}
|
||||
],
|
||||
"pattern": "justj4nn3",
|
||||
"rule_id": "justj4nn3",
|
||||
"default": false,
|
||||
"enabled": true,
|
||||
"kind": "content"
|
||||
},
|
||||
{
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "sound",
|
||||
"value": "default"
|
||||
},
|
||||
{
|
||||
"set_tweak": "highlight"
|
||||
}
|
||||
],
|
||||
"pattern": "justj4nne",
|
||||
"rule_id": "justj4nne",
|
||||
"default": false,
|
||||
"enabled": true,
|
||||
"kind": "content"
|
||||
},
|
||||
{
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "sound",
|
||||
"value": "default"
|
||||
},
|
||||
{
|
||||
"set_tweak": "highlight",
|
||||
"value": true
|
||||
}
|
||||
],
|
||||
"pattern": "Janne",
|
||||
"rule_id": "Janne",
|
||||
"default": false,
|
||||
"enabled": true,
|
||||
"kind": "content"
|
||||
},
|
||||
{
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "sound",
|
||||
"value": "default"
|
||||
},
|
||||
{
|
||||
"set_tweak": "highlight"
|
||||
}
|
||||
],
|
||||
"pattern": "J4nne",
|
||||
"rule_id": "J4nne",
|
||||
"default": false,
|
||||
"enabled": true,
|
||||
"kind": "content"
|
||||
},
|
||||
{
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "sound",
|
||||
"value": "default"
|
||||
},
|
||||
{
|
||||
"set_tweak": "highlight"
|
||||
}
|
||||
],
|
||||
"pattern": "Jann3",
|
||||
"rule_id": "Jann3",
|
||||
"default": false,
|
||||
"enabled": true,
|
||||
"kind": "content"
|
||||
},
|
||||
{
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "sound",
|
||||
"value": "default"
|
||||
},
|
||||
{
|
||||
"set_tweak": "highlight"
|
||||
}
|
||||
],
|
||||
"pattern": "jann3",
|
||||
"rule_id": "jann3",
|
||||
"default": false,
|
||||
"enabled": true,
|
||||
"kind": "content"
|
||||
},
|
||||
{
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "sound",
|
||||
"value": "default"
|
||||
},
|
||||
{
|
||||
"set_tweak": "highlight"
|
||||
}
|
||||
],
|
||||
"pattern": "j4nne",
|
||||
"rule_id": "j4nne",
|
||||
"default": false,
|
||||
"enabled": true,
|
||||
"kind": "content"
|
||||
},
|
||||
{
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "sound",
|
||||
"value": "default"
|
||||
},
|
||||
{
|
||||
"set_tweak": "highlight"
|
||||
}
|
||||
],
|
||||
"pattern": "janne",
|
||||
"rule_id": "janne",
|
||||
"default": false,
|
||||
"enabled": true,
|
||||
"kind": "content"
|
||||
},
|
||||
{
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "sound",
|
||||
"value": "default"
|
||||
},
|
||||
{
|
||||
"set_tweak": "highlight"
|
||||
}
|
||||
],
|
||||
"rule_id": ".m.rule.contains_user_name",
|
||||
"default": true,
|
||||
"pattern": "jannemk",
|
||||
"enabled": true,
|
||||
"kind": "content"
|
||||
}
|
||||
],
|
||||
"override": [
|
||||
{
|
||||
"conditions": [],
|
||||
"actions": ["dont_notify"],
|
||||
"rule_id": ".m.rule.master",
|
||||
"default": true,
|
||||
"enabled": false,
|
||||
"kind": "override"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "content.msgtype",
|
||||
"pattern": "m.notice"
|
||||
}
|
||||
],
|
||||
"actions": ["dont_notify"],
|
||||
"rule_id": ".m.rule.suppress_notices",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "override"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "m.room.member"
|
||||
},
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "content.membership",
|
||||
"pattern": "invite"
|
||||
},
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "state_key",
|
||||
"pattern": "@jannemk:element.io"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "highlight",
|
||||
"value": false
|
||||
}
|
||||
],
|
||||
"rule_id": ".m.rule.invite_for_me",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "override"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "m.room.member"
|
||||
}
|
||||
],
|
||||
"actions": ["dont_notify"],
|
||||
"rule_id": ".m.rule.member_event",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "override"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "contains_display_name"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "sound",
|
||||
"value": "default"
|
||||
},
|
||||
{
|
||||
"set_tweak": "highlight"
|
||||
}
|
||||
],
|
||||
"rule_id": ".m.rule.contains_display_name",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "override"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "sender_notification_permission",
|
||||
"key": "room"
|
||||
},
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "content.body",
|
||||
"pattern": "@room"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "highlight",
|
||||
"value": false
|
||||
}
|
||||
],
|
||||
"rule_id": ".m.rule.roomnotif",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "override"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "m.room.tombstone"
|
||||
},
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "state_key",
|
||||
"pattern": ""
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "highlight",
|
||||
"value": true
|
||||
}
|
||||
],
|
||||
"rule_id": ".m.rule.tombstone",
|
||||
"default": true,
|
||||
"enabled": false,
|
||||
"kind": "override"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "m.reaction"
|
||||
}
|
||||
],
|
||||
"actions": ["dont_notify"],
|
||||
"rule_id": ".m.rule.reaction",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "override"
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "m.room.server_acl"
|
||||
},
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "state_key",
|
||||
"pattern": ""
|
||||
}
|
||||
],
|
||||
"actions": [],
|
||||
"rule_id": ".m.rule.room.server_acl",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"kind": "override"
|
||||
},
|
||||
{
|
||||
"rule_id": ".org.matrix.msc3952.is_user_mention",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_property_contains",
|
||||
"key": "content.org\\.matrix\\.msc3952\\.mentions.user_ids",
|
||||
"value": "@jannemk:element.io"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "highlight"
|
||||
}
|
||||
],
|
||||
"kind": "override"
|
||||
},
|
||||
{
|
||||
"rule_id": ".org.matrix.msc3952.is_room_mention",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_property_is",
|
||||
"key": "content.org\\.matrix\\.msc3952\\.mentions.room",
|
||||
"value": true
|
||||
},
|
||||
{
|
||||
"kind": "sender_notification_permission",
|
||||
"key": "room"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "highlight"
|
||||
}
|
||||
],
|
||||
"kind": "override"
|
||||
},
|
||||
{
|
||||
"rule_id": ".org.matrix.msc3786.rule.room.server_acl",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "type",
|
||||
"pattern": "m.room.server_acl"
|
||||
},
|
||||
{
|
||||
"kind": "event_match",
|
||||
"key": "state_key",
|
||||
"pattern": ""
|
||||
}
|
||||
],
|
||||
"actions": [],
|
||||
"kind": "override"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue