summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
Diffstat (limited to 'synapse')
-rw-r--r--synapse/events/utils.py8
-rw-r--r--synapse/rest/client/relations.py9
2 files changed, 11 insertions, 6 deletions
diff --git a/synapse/events/utils.py b/synapse/events/utils.py
index e5967c995e..05219a9dd0 100644
--- a/synapse/events/utils.py
+++ b/synapse/events/utils.py
@@ -435,6 +435,14 @@ class EventClientSerializer:
             serialized_event: The serialized event which may be modified.
 
         """
+        # Do not bundle relations for an event which represents an edit or an
+        # annotation. It does not make sense for them to have related events.
+        relates_to = event.content.get("m.relates_to")
+        if isinstance(relates_to, (dict, frozendict)):
+            relation_type = relates_to.get("rel_type")
+            if relation_type in (RelationTypes.ANNOTATION, RelationTypes.REPLACE):
+                return
+
         event_id = event.event_id
 
         # The bundled relations to include.
diff --git a/synapse/rest/client/relations.py b/synapse/rest/client/relations.py
index 45e9f1dd90..b1a3304849 100644
--- a/synapse/rest/client/relations.py
+++ b/synapse/rest/client/relations.py
@@ -230,12 +230,9 @@ class RelationPaginationServlet(RestServlet):
         original_event = await self._event_serializer.serialize_event(
             event, now, bundle_relations=False
         )
-        # Similarly, we don't allow relations to be applied to relations, so we
-        # return the original relations without any aggregations on top of them
-        # here.
-        serialized_events = await self._event_serializer.serialize_events(
-            events, now, bundle_relations=False
-        )
+        # The relations returned for the requested event do include their
+        # bundled relations.
+        serialized_events = await self._event_serializer.serialize_events(events, now)
 
         return_value = pagination_chunk.to_dict()
         return_value["chunk"] = serialized_events