Consolidate logic for parsing relations. (#12693)

Parse the `m.relates_to` event content field (which describes relations)
in a single place, this is used during:

* Event persistence.
* Validation of the Client-Server API.
* Fetching bundled aggregations.
* Processing of push rules.

Each of these separately implement the logic and each made slightly
different assumptions about what was valid. Some had minor / potential
bugs.
This commit is contained in:
Patrick Cloke 2022-05-16 08:42:45 -04:00 committed by GitHub
parent cde8af9a49
commit 86a515ccbf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 98 additions and 61 deletions

View file

@ -656,12 +656,13 @@ class UnreadMessagesTestCase(unittest.HomeserverTestCase):
self._check_unread_count(3)
# Check that custom events with a body increase the unread counter.
self.helper.send_event(
result = self.helper.send_event(
self.room_id,
"org.matrix.custom_type",
{"body": "hello"},
tok=self.tok2,
)
event_id = result["event_id"]
self._check_unread_count(4)
# Check that edits don't increase the unread counter.
@ -671,7 +672,10 @@ class UnreadMessagesTestCase(unittest.HomeserverTestCase):
content={
"body": "hello",
"msgtype": "m.text",
"m.relates_to": {"rel_type": RelationTypes.REPLACE},
"m.relates_to": {
"rel_type": RelationTypes.REPLACE,
"event_id": event_id,
},
},
tok=self.tok2,
)