mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-04 23:15:02 -04:00
Allow retrieving the relations of a redacted event. (#12130)
This is allowed per MSC2675, although the original implementation did not allow for it and would return an empty chunk / not bundle aggregations. The main thing to improve is that the various caches get cleared properly when an event is redacted, and that edits must not leak if the original event is redacted (as that would presumably leak something similar to the original event content).
This commit is contained in:
parent
3e4af36bc8
commit
88cd6f9378
8 changed files with 119 additions and 80 deletions
|
@ -1475,12 +1475,13 @@ class RelationRedactionTestCase(BaseRelationsTestCase):
|
|||
self.assertEqual(relations, {})
|
||||
|
||||
def test_redact_parent_annotation(self) -> None:
|
||||
"""Test that annotations of an event are redacted when the original event
|
||||
"""Test that annotations of an event are viewable when the original event
|
||||
is redacted.
|
||||
"""
|
||||
# Add a relation
|
||||
channel = self._send_relation(RelationTypes.ANNOTATION, "m.reaction", key="👍")
|
||||
self.assertEqual(200, channel.code, channel.json_body)
|
||||
related_event_id = channel.json_body["event_id"]
|
||||
|
||||
# The relations should exist.
|
||||
event_ids, relations = self._make_relation_requests()
|
||||
|
@ -1494,11 +1495,45 @@ class RelationRedactionTestCase(BaseRelationsTestCase):
|
|||
# Redact the original event.
|
||||
self._redact(self.parent_id)
|
||||
|
||||
# The relations are not returned.
|
||||
# The relations are returned.
|
||||
event_ids, relations = self._make_relation_requests()
|
||||
self.assertEqual(event_ids, [])
|
||||
self.assertEqual(relations, {})
|
||||
self.assertEquals(event_ids, [related_event_id])
|
||||
self.assertEquals(
|
||||
relations["m.annotation"],
|
||||
{"chunk": [{"type": "m.reaction", "key": "👍", "count": 1}]},
|
||||
)
|
||||
|
||||
# There's nothing to aggregate.
|
||||
chunk = self._get_aggregations()
|
||||
self.assertEqual(chunk, [])
|
||||
self.assertEqual(chunk, [{"count": 1, "key": "👍", "type": "m.reaction"}])
|
||||
|
||||
@unittest.override_config({"experimental_features": {"msc3440_enabled": True}})
|
||||
def test_redact_parent_thread(self) -> None:
|
||||
"""
|
||||
Test that thread replies are still available when the root event is redacted.
|
||||
"""
|
||||
channel = self._send_relation(
|
||||
RelationTypes.THREAD,
|
||||
EventTypes.Message,
|
||||
content={"body": "reply 1", "msgtype": "m.text"},
|
||||
)
|
||||
self.assertEqual(200, channel.code, channel.json_body)
|
||||
related_event_id = channel.json_body["event_id"]
|
||||
|
||||
# Redact one of the reactions.
|
||||
self._redact(self.parent_id)
|
||||
|
||||
# The unredacted relation should still exist.
|
||||
event_ids, relations = self._make_relation_requests()
|
||||
self.assertEquals(len(event_ids), 1)
|
||||
self.assertDictContainsSubset(
|
||||
{
|
||||
"count": 1,
|
||||
"current_user_participated": True,
|
||||
},
|
||||
relations[RelationTypes.THREAD],
|
||||
)
|
||||
self.assertEqual(
|
||||
relations[RelationTypes.THREAD]["latest_event"]["event_id"],
|
||||
related_event_id,
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue