diff --git a/synapse/events/utils.py b/synapse/events/utils.py
index 918e87ed9c..2174b4a094 100644
--- a/synapse/events/utils.py
+++ b/synapse/events/utils.py
@@ -39,7 +39,6 @@ from . import EventBase
if TYPE_CHECKING:
from synapse.handlers.relations import BundledAggregations
- from synapse.server import HomeServer
# Split strings on "." but not "\." This uses a negative lookbehind assertion for '\'
@@ -396,9 +395,6 @@ class EventClientSerializer:
clients.
"""
- def __init__(self, hs: "HomeServer"):
- self._msc3440_enabled = hs.config.experimental.msc3440_enabled
-
def serialize_event(
self,
event: Union[JsonDict, EventBase],
@@ -406,6 +402,7 @@ class EventClientSerializer:
*,
config: SerializeEventConfig = _DEFAULT_SERIALIZE_EVENT_CONFIG,
bundle_aggregations: Optional[Dict[str, "BundledAggregations"]] = None,
+ apply_edits: bool = True,
) -> JsonDict:
"""Serializes a single event.
@@ -413,10 +410,10 @@ class EventClientSerializer:
event: The event being serialized.
time_now: The current time in milliseconds
config: Event serialization config
- bundle_aggregations: Whether to include the bundled aggregations for this
- event. Only applies to non-state events. (State events never include
- bundled aggregations.)
-
+ bundle_aggregations: A map from event_id to the aggregations to be bundled
+ into the event.
+ apply_edits: Whether the content of the event should be modified to reflect
+ any replacement in `bundle_aggregations[<event_id>].replace`.
Returns:
The serialized event
"""
@@ -434,8 +431,9 @@ class EventClientSerializer:
event,
time_now,
config,
- bundle_aggregations[event.event_id],
+ event_aggregations,
serialized_event,
+ apply_edits=apply_edits,
)
return serialized_event
@@ -474,6 +472,7 @@ class EventClientSerializer:
config: SerializeEventConfig,
aggregations: "BundledAggregations",
serialized_event: JsonDict,
+ apply_edits: bool,
) -> None:
"""Potentially injects bundled aggregations into the unsigned portion of the serialized event.
@@ -483,7 +482,8 @@ class EventClientSerializer:
aggregations: The bundled aggregation to serialize.
serialized_event: The serialized event which may be modified.
config: Event serialization config
-
+ apply_edits: Whether the content of the event should be modified to reflect
+ any replacement in `aggregations.replace`.
"""
serialized_aggregations = {}
@@ -494,9 +494,10 @@ class EventClientSerializer:
serialized_aggregations[RelationTypes.REFERENCE] = aggregations.references
if aggregations.replace:
- # If there is an edit, apply it to the event.
+ # If there is an edit, optionally apply it to the event.
edit = aggregations.replace
- self._apply_edit(event, serialized_event, edit)
+ if apply_edits:
+ self._apply_edit(event, serialized_event, edit)
# Include information about it in the relations dict.
serialized_aggregations[RelationTypes.REPLACE] = {
@@ -525,8 +526,6 @@ class EventClientSerializer:
"current_user_participated": thread.current_user_participated,
}
serialized_aggregations[RelationTypes.THREAD] = thread_summary
- if self._msc3440_enabled:
- serialized_aggregations[RelationTypes.UNSTABLE_THREAD] = thread_summary
# Include the bundled aggregations in the event.
if serialized_aggregations:
|