From 2de7ef9a3d1305edffd7774fe22ea140b9903966 Mon Sep 17 00:00:00 2001 From: Anatoly Sablin Date: Fri, 15 Feb 2019 23:23:38 +0300 Subject: [PATCH 1/4] #1865 Add the m.push_rules schema. --- event-schemas/examples/m.push_rules | 192 ++++++++++++++++++ .../schema/core-event-schema/push_rule.yaml | 85 ++++++++ event-schemas/schema/m.push_rules | 59 ++++++ specification/modules/push.rst | 2 + 4 files changed, 338 insertions(+) create mode 100644 event-schemas/examples/m.push_rules create mode 100644 event-schemas/schema/core-event-schema/push_rule.yaml create mode 100644 event-schemas/schema/m.push_rules diff --git a/event-schemas/examples/m.push_rules b/event-schemas/examples/m.push_rules new file mode 100644 index 000000000..9785da253 --- /dev/null +++ b/event-schemas/examples/m.push_rules @@ -0,0 +1,192 @@ +{ + "$ref": "core/state_event.json", + "type": "m.push_rules", + "content": { + "global": { + "content": [ + { + "actions": [ + "notify", + { + "set_tweak": "sound", + "value": "default" + }, + { + "set_tweak": "highlight" + } + ], + "default": true, + "enabled": true, + "pattern": "alice", + "rule_id": ".m.rule.contains_user_name" + } + ], + "override": [ + { + "actions": [ + "dont_notify" + ], + "conditions": [], + "default": true, + "enabled": false, + "rule_id": ".m.rule.master" + }, + { + "actions": [ + "dont_notify" + ], + "conditions": [ + { + "key": "content.msgtype", + "kind": "event_match", + "pattern": "m.notice" + } + ], + "default": true, + "enabled": true, + "rule_id": ".m.rule.suppress_notices" + } + ], + "room": [], + "sender": [], + "underride": [ + { + "actions": [ + "notify", + { + "set_tweak": "sound", + "value": "ring" + }, + { + "set_tweak": "highlight", + "value": false + } + ], + "conditions": [ + { + "key": "type", + "kind": "event_match", + "pattern": "m.call.invite" + } + ], + "default": true, + "enabled": true, + "rule_id": ".m.rule.call" + }, + { + "actions": [ + "notify", + { + "set_tweak": "sound", + "value": "default" + }, + { + "set_tweak": "highlight" + } + ], + "conditions": [ + { + "kind": "contains_display_name" + } + ], + "default": true, + "enabled": true, + "rule_id": ".m.rule.contains_display_name" + }, + { + "actions": [ + "notify", + { + "set_tweak": "sound", + "value": "default" + }, + { + "set_tweak": "highlight", + "value": false + } + ], + "conditions": [ + { + "is": "2", + "kind": "room_member_count" + } + ], + "default": true, + "enabled": true, + "rule_id": ".m.rule.room_one_to_one" + }, + { + "actions": [ + "notify", + { + "set_tweak": "sound", + "value": "default" + }, + { + "set_tweak": "highlight", + "value": false + } + ], + "conditions": [ + { + "key": "type", + "kind": "event_match", + "pattern": "m.room.member" + }, + { + "key": "content.membership", + "kind": "event_match", + "pattern": "invite" + }, + { + "key": "state_key", + "kind": "event_match", + "pattern": "@alice:example.com" + } + ], + "default": true, + "enabled": true, + "rule_id": ".m.rule.invite_for_me" + }, + { + "actions": [ + "notify", + { + "set_tweak": "highlight", + "value": false + } + ], + "conditions": [ + { + "key": "type", + "kind": "event_match", + "pattern": "m.room.member" + } + ], + "default": true, + "enabled": true, + "rule_id": ".m.rule.member_event" + }, + { + "actions": [ + "notify", + { + "set_tweak": "highlight", + "value": false + } + ], + "conditions": [ + { + "key": "type", + "kind": "event_match", + "pattern": "m.room.message" + } + ], + "default": true, + "enabled": true, + "rule_id": ".m.rule.message" + } + ] + } + } +} diff --git a/event-schemas/schema/core-event-schema/push_rule.yaml b/event-schemas/schema/core-event-schema/push_rule.yaml new file mode 100644 index 000000000..a7626bbeb --- /dev/null +++ b/event-schemas/schema/core-event-schema/push_rule.yaml @@ -0,0 +1,85 @@ +# Copyright 2016 OpenMarket Ltd +# +# 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. + +title: PushRule +type: object +properties: + actions: + items: + type: + - object + - string + type: array + description: |- + The actions to perform when this rule is matched. + default: + type: boolean + description: |- + Whether this is a default rule, or has been set explicitly. + enabled: + type: boolean + description: |- + Whether the push rule is enabled or not. + rule_id: + type: string + description: |- + The ID of this rule. + conditions: + type: array + items: + title: PushCondition + type: object + properties: + kind: + enum: + - event_match + - contains_display_name + - room_member_count + type: string + key: + type: string + description: |- + Required for ``event_match`` conditions. The dot-separated field of the + event to match. + x-example: content.body + pattern: + type: string + description: |- + Required for ``event_match`` conditions. The glob-style pattern to + match against. Patterns with no special glob characters should be + treated as having asterisks prepended and appended when testing the + condition. + is: + type: string + description: |- + Required for ``room_member_count`` conditions. A decimal integer + optionally prefixed by one of, ==, <, >, >= or <=. A prefix of < matches + rooms where the member count is strictly less than the given number and + so forth. If no prefix is present, this parameter defaults to ==. + required: + - kind + description: |- + The conditions that must hold true for an event in order for a rule to be + applied to an event. A rule with no conditions always matches. Only + applicable to ``underride`` and ``override`` rules. + pattern: + type: string + description: |- + The glob-style pattern to match against. Only applicable to ``content`` + rules. +required: + - actions + - default + - enabled + - rule_id diff --git a/event-schemas/schema/m.push_rules b/event-schemas/schema/m.push_rules new file mode 100644 index 000000000..b487a6f54 --- /dev/null +++ b/event-schemas/schema/m.push_rules @@ -0,0 +1,59 @@ +--- +allOf: + - $ref: core-event-schema/state_event.yaml +description: Describes all push rules for this user. +properties: + content: + properties: + global: + type: object + title: Ruleset + description: The global ruleset + properties: + content: + items: + allOf: + - $ref: core-event-schema/push_rule.yaml + title: PushRule + type: object + type: array + override: + items: + allOf: + - $ref: core-event-schema/push_rule.yaml + title: PushRule + type: object + type: array + room: + items: + allOf: + - $ref: core-event-schema/push_rule.yaml + title: PushRule + type: object + type: array + sender: + items: + allOf: + - $ref: core-event-schema/push_rule.yaml + title: PushRule + type: object + type: array + underride: + items: + allOf: + - $ref: core-event-schema/push_rule.yaml + title: PushRule + type: object + type: array + type: object + state_key: + description: A zero-length string. + pattern: '^$' + type: string + type: + enum: + - m.push_rules + type: string +title: Push rules +type: object + diff --git a/specification/modules/push.rst b/specification/modules/push.rst index 008eaa8b6..9830729a1 100644 --- a/specification/modules/push.rst +++ b/specification/modules/push.rst @@ -660,6 +660,8 @@ When a user changes their push rules a ``m.push_rules`` event is sent to all clients in the ``account_data`` section of their next ``/sync`` request. The content of the event is the current push rules for the user. +{{m_push_rules_event}} + Examples ++++++++ From d4b4d92b827a41ec1fcda1e799dd2a3f67edf8bb Mon Sep 17 00:00:00 2001 From: Anatoly Sablin Date: Sat, 16 Feb 2019 00:24:26 +0300 Subject: [PATCH 2/4] Fix the m.push_rules type (switch from the state event to the common event). --- event-schemas/examples/m.push_rules | 2 +- event-schemas/schema/m.push_rules | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/event-schemas/examples/m.push_rules b/event-schemas/examples/m.push_rules index 9785da253..e4f0a959f 100644 --- a/event-schemas/examples/m.push_rules +++ b/event-schemas/examples/m.push_rules @@ -1,5 +1,5 @@ { - "$ref": "core/state_event.json", + "$ref": "core/event.json", "type": "m.push_rules", "content": { "global": { diff --git a/event-schemas/schema/m.push_rules b/event-schemas/schema/m.push_rules index b487a6f54..ededb33ed 100644 --- a/event-schemas/schema/m.push_rules +++ b/event-schemas/schema/m.push_rules @@ -1,6 +1,6 @@ --- allOf: - - $ref: core-event-schema/state_event.yaml + - $ref: core-event-schema/event.yaml description: Describes all push rules for this user. properties: content: @@ -46,10 +46,6 @@ properties: type: object type: array type: object - state_key: - description: A zero-length string. - pattern: '^$' - type: string type: enum: - m.push_rules From 4bec3d6dd866e9ba4843a7f55dd87f841d50f1e9 Mon Sep 17 00:00:00 2001 From: Anatoly Sablin Date: Sun, 24 Feb 2019 19:43:03 +0300 Subject: [PATCH 3/4] Avoid duplicates. --- .../schema/core-event-schema/push_rule.yaml | 85 ------------------- event-schemas/schema/m.push_rules | 38 +-------- 2 files changed, 2 insertions(+), 121 deletions(-) delete mode 100644 event-schemas/schema/core-event-schema/push_rule.yaml diff --git a/event-schemas/schema/core-event-schema/push_rule.yaml b/event-schemas/schema/core-event-schema/push_rule.yaml deleted file mode 100644 index a7626bbeb..000000000 --- a/event-schemas/schema/core-event-schema/push_rule.yaml +++ /dev/null @@ -1,85 +0,0 @@ -# Copyright 2016 OpenMarket Ltd -# -# 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. - -title: PushRule -type: object -properties: - actions: - items: - type: - - object - - string - type: array - description: |- - The actions to perform when this rule is matched. - default: - type: boolean - description: |- - Whether this is a default rule, or has been set explicitly. - enabled: - type: boolean - description: |- - Whether the push rule is enabled or not. - rule_id: - type: string - description: |- - The ID of this rule. - conditions: - type: array - items: - title: PushCondition - type: object - properties: - kind: - enum: - - event_match - - contains_display_name - - room_member_count - type: string - key: - type: string - description: |- - Required for ``event_match`` conditions. The dot-separated field of the - event to match. - x-example: content.body - pattern: - type: string - description: |- - Required for ``event_match`` conditions. The glob-style pattern to - match against. Patterns with no special glob characters should be - treated as having asterisks prepended and appended when testing the - condition. - is: - type: string - description: |- - Required for ``room_member_count`` conditions. A decimal integer - optionally prefixed by one of, ==, <, >, >= or <=. A prefix of < matches - rooms where the member count is strictly less than the given number and - so forth. If no prefix is present, this parameter defaults to ==. - required: - - kind - description: |- - The conditions that must hold true for an event in order for a rule to be - applied to an event. A rule with no conditions always matches. Only - applicable to ``underride`` and ``override`` rules. - pattern: - type: string - description: |- - The glob-style pattern to match against. Only applicable to ``content`` - rules. -required: - - actions - - default - - enabled - - rule_id diff --git a/event-schemas/schema/m.push_rules b/event-schemas/schema/m.push_rules index ededb33ed..6fde9e148 100644 --- a/event-schemas/schema/m.push_rules +++ b/event-schemas/schema/m.push_rules @@ -9,42 +9,8 @@ properties: type: object title: Ruleset description: The global ruleset - properties: - content: - items: - allOf: - - $ref: core-event-schema/push_rule.yaml - title: PushRule - type: object - type: array - override: - items: - allOf: - - $ref: core-event-schema/push_rule.yaml - title: PushRule - type: object - type: array - room: - items: - allOf: - - $ref: core-event-schema/push_rule.yaml - title: PushRule - type: object - type: array - sender: - items: - allOf: - - $ref: core-event-schema/push_rule.yaml - title: PushRule - type: object - type: array - underride: - items: - allOf: - - $ref: core-event-schema/push_rule.yaml - title: PushRule - type: object - type: array + allOf: + - $ref: ../../api/client-server/definitions/push_ruleset.yaml type: object type: enum: From 5303ba54b72a926e029528a9e96c7fb75925d51a Mon Sep 17 00:00:00 2001 From: Anatoly Sablin Date: Thu, 28 Feb 2019 21:04:23 +0300 Subject: [PATCH 4/4] Add a clarification changelog. --- changelogs/client_server/newsfragments/1889.clarification | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelogs/client_server/newsfragments/1889.clarification diff --git a/changelogs/client_server/newsfragments/1889.clarification b/changelogs/client_server/newsfragments/1889.clarification new file mode 100644 index 000000000..5026dab38 --- /dev/null +++ b/changelogs/client_server/newsfragments/1889.clarification @@ -0,0 +1 @@ +Add the missing `m.push_rules` event schema.