Implement MSC3958: suppress notifications from edits (#14960)

Co-authored-by: Brad Murray <brad@beeper.com>
Co-authored-by: Nick Barrett <nick@beeper.com>

Copy the suppress_edits push rule from Beeper to implement MSC3958.

9415a1284b/rust/src/push/base_rules.rs (L98-L114)
This commit is contained in:
Patrick Cloke 2023-02-03 14:31:14 -05:00 committed by GitHub
parent e301ee6189
commit b2d97bac09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 76 additions and 2 deletions

View file

@ -19,7 +19,7 @@ from parameterized import parameterized
from twisted.test.proto_helpers import MemoryReactor
from synapse.api.constants import EventContentFields
from synapse.api.constants import EventContentFields, RelationTypes
from synapse.api.room_versions import RoomVersions
from synapse.push.bulk_push_rule_evaluator import BulkPushRuleEvaluator
from synapse.rest import admin
@ -370,3 +370,43 @@ class TestBulkPushRuleEvaluator(HomeserverTestCase):
},
)
)
@override_config({"experimental_features": {"msc3958_supress_edit_notifs": True}})
def test_suppress_edits(self) -> None:
"""Under the default push rules, event edits should not generate notifications."""
bulk_evaluator = BulkPushRuleEvaluator(self.hs)
# Create & persist an event to use as the parent of the relation.
event, context = self.get_success(
self.event_creation_handler.create_event(
self.requester,
{
"type": "m.room.message",
"room_id": self.room_id,
"content": {
"msgtype": "m.text",
"body": "helo",
},
"sender": self.alice,
},
)
)
self.get_success(
self.event_creation_handler.handle_new_client_event(
self.requester, events_and_context=[(event, context)]
)
)
# Room mentions from those without power should not notify.
self.assertFalse(
self._create_and_process(
bulk_evaluator,
{
"body": self.alice,
"m.relates_to": {
"rel_type": RelationTypes.REPLACE,
"event_id": event.event_id,
},
},
)
)