From 54cd2d4317cd82cc494ef9e6fbdcb6c22dfaf678 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Fri, 29 Apr 2022 18:54:34 +0200 Subject: [PATCH 1/6] Add `DEFAULT_OVERRIDE_RULES` for `RoomServerAcl` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/pushprocessor.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/pushprocessor.ts b/src/pushprocessor.ts index ae170751f00..f18b92ed958 100644 --- a/src/pushprocessor.ts +++ b/src/pushprocessor.ts @@ -34,6 +34,7 @@ import { PushRuleSet, TweakName, } from "./@types/PushRules"; +import { EventType } from "./@types/event"; /** * @module pushprocessor @@ -96,6 +97,22 @@ const DEFAULT_OVERRIDE_RULES: IPushRule[] = [ PushRuleActionName.DontNotify, ], }, + { + // Make sure we don't notify on ACL changes - https://github.com/vector-im/element-web/issues/20788 + rule_id: ".m.rule.server_acl", + default: true, + enabled: true, + conditions: [ + { + kind: ConditionKind.EventMatch, + key: "type", + pattern: EventType.RoomServerAcl, + }, + ], + actions: [ + PushRuleActionName.DontNotify, + ], + }, ]; export interface IActionsObject { From 952bf4d5e4a9c22133d54dab8e0387c34335c454 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Fri, 29 Apr 2022 18:55:14 +0200 Subject: [PATCH 2/6] Add `should not bing on room server ACL changes` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- spec/unit/pushprocessor.spec.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/spec/unit/pushprocessor.spec.js b/spec/unit/pushprocessor.spec.js index 85fadcf78c1..df7666d5cd3 100644 --- a/spec/unit/pushprocessor.spec.js +++ b/spec/unit/pushprocessor.spec.js @@ -1,5 +1,6 @@ import * as utils from "../test-utils/test-utils"; import { PushProcessor } from "../../src/pushprocessor"; +import { EventType } from "../../src"; describe('NotificationService', function() { const testUserId = "@ali:matrix.org"; @@ -208,6 +209,7 @@ describe('NotificationService', function() { msgtype: "m.text", }, }); + matrixClient.pushRules = PushProcessor.rewriteDefaultRules(matrixClient.pushRules); pushProcessor = new PushProcessor(matrixClient); }); @@ -295,6 +297,21 @@ describe('NotificationService', function() { expect(actions.tweaks.highlight).toEqual(false); }); + it('should not bing on room server ACL changes', function() { + testEvent = utils.mkEvent({ + type: EventType.RoomServerAcl, + room: testRoomId, + user: "@alfred:localhost", + event: true, + content: {}, + }); + + const actions = pushProcessor.actionsForEvent(testEvent); + expect(actions.tweaks.highlight).toBeFalsy(); + expect(actions.tweaks.sound).toBeFalsy(); + expect(actions.notify).toBeFalsy(); + }); + // invalid it('should gracefully handle bad input.', function() { From 3d380ba34be0a80b21a45c4a31f1e0980d939213 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Sat, 30 Apr 2022 17:00:40 +0200 Subject: [PATCH 3/6] Use MSC prefix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/pushprocessor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pushprocessor.ts b/src/pushprocessor.ts index f18b92ed958..e7bf925827e 100644 --- a/src/pushprocessor.ts +++ b/src/pushprocessor.ts @@ -99,7 +99,7 @@ const DEFAULT_OVERRIDE_RULES: IPushRule[] = [ }, { // Make sure we don't notify on ACL changes - https://github.com/vector-im/element-web/issues/20788 - rule_id: ".m.rule.server_acl", + rule_id: "org.matrix.msc0000.rule.room.server_acl", default: true, enabled: true, conditions: [ From ba60f4dc38f01d9bcf59f5cf59e1921121fe3666 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Sat, 30 Apr 2022 17:09:01 +0200 Subject: [PATCH 4/6] Update comment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/pushprocessor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pushprocessor.ts b/src/pushprocessor.ts index e7bf925827e..5f07f2bf2f0 100644 --- a/src/pushprocessor.ts +++ b/src/pushprocessor.ts @@ -98,7 +98,7 @@ const DEFAULT_OVERRIDE_RULES: IPushRule[] = [ ], }, { - // Make sure we don't notify on ACL changes - https://github.com/vector-im/element-web/issues/20788 + // For homeservers which don't support MSC3786 yet rule_id: "org.matrix.msc0000.rule.room.server_acl", default: true, enabled: true, From 62c72c85cf59d5e9c7526b629bd2baf1a5633acf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Sat, 30 Apr 2022 18:37:29 +0200 Subject: [PATCH 5/6] Add prefix `.` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/pushprocessor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pushprocessor.ts b/src/pushprocessor.ts index 5f07f2bf2f0..7d17427bbc4 100644 --- a/src/pushprocessor.ts +++ b/src/pushprocessor.ts @@ -99,7 +99,7 @@ const DEFAULT_OVERRIDE_RULES: IPushRule[] = [ }, { // For homeservers which don't support MSC3786 yet - rule_id: "org.matrix.msc0000.rule.room.server_acl", + rule_id: ".org.matrix.msc0000.rule.room.server_acl", default: true, enabled: true, conditions: [ From 65c8b54b187f26e661023e0a1322cbc8a1e06bc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Wed, 4 May 2022 11:27:28 +0200 Subject: [PATCH 6/6] Update src/pushprocessor.ts Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> --- src/pushprocessor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pushprocessor.ts b/src/pushprocessor.ts index 7d17427bbc4..86462b4af43 100644 --- a/src/pushprocessor.ts +++ b/src/pushprocessor.ts @@ -99,7 +99,7 @@ const DEFAULT_OVERRIDE_RULES: IPushRule[] = [ }, { // For homeservers which don't support MSC3786 yet - rule_id: ".org.matrix.msc0000.rule.room.server_acl", + rule_id: ".org.matrix.msc3786.rule.room.server_acl", default: true, enabled: true, conditions: [