Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Include bundled aggregations for redacted events.
Browse files Browse the repository at this point in the history
But do NOT include edits of redacted events.
  • Loading branch information
clokep committed Mar 2, 2022
1 parent df21a27 commit 4b4337a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
16 changes: 10 additions & 6 deletions synapse/storage/databases/main/relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,11 +811,9 @@ async def get_bundled_aggregations(
"""
# De-duplicate events by ID to handle the same event requested multiple times.
#
# State events and redacted events do not get bundled aggregations.
# State events do not get bundled aggregations.
events_by_id = {
event.event_id: event
for event in events
if not event.is_state() and not event.internal_metadata.is_redacted()
event.event_id: event for event in events if not event.is_state()
}

# event ID -> bundled aggregation in non-serialized form.
Expand All @@ -827,8 +825,14 @@ async def get_bundled_aggregations(
if event_result:
results[event.event_id] = event_result

# Fetch any edits.
edits = await self._get_applicable_edits(events_by_id.keys())
# Fetch any edits (but not for redacted events).
edits = await self._get_applicable_edits(
[
event_id
for event_id, event in events_by_id.items()
if not event.internal_metadata.is_redacted()
]
)
for event_id, edit in edits.items():
results.setdefault(event_id, BundledAggregations()).replace = edit

Expand Down
5 changes: 4 additions & 1 deletion tests/rest/client/test_relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1571,7 +1571,10 @@ def test_redact_parent_annotation(self) -> None:
# The relations are returned.
event_ids, relations = self._make_relation_requests()
self.assertEquals(event_ids, [related_event_id])
self.assertEqual(relations, {})
self.assertEquals(
relations["m.annotation"],
{"chunk": [{"type": "m.reaction", "key": "👍", "count": 1}]},
)

# There's nothing to aggregate.
chunk = self._get_aggregations()
Expand Down

0 comments on commit 4b4337a

Please sign in to comment.