mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-12-17 17:34:21 -05:00
Do not bundle aggregations for APIs which shouldn't include them. (#11592)
And make bundling aggregations opt-in, instead of opt-out to avoid having APIs to include extraneous data (and being much heavier than necessary).
This commit is contained in:
parent
c3e38b88f2
commit
dd47788752
1
changelog.d/11592.bugfix
Normal file
1
changelog.d/11592.bugfix
Normal file
@ -0,0 +1 @@
|
|||||||
|
Fix a long-standing bug where responses included bundled aggregations when they should not, per [MSC2675](https://github.com/matrix-org/matrix-doc/pull/2675).
|
@ -395,7 +395,7 @@ class EventClientSerializer:
|
|||||||
event: Union[JsonDict, EventBase],
|
event: Union[JsonDict, EventBase],
|
||||||
time_now: int,
|
time_now: int,
|
||||||
*,
|
*,
|
||||||
bundle_aggregations: bool = True,
|
bundle_aggregations: bool = False,
|
||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> JsonDict:
|
) -> JsonDict:
|
||||||
"""Serializes a single event.
|
"""Serializes a single event.
|
||||||
|
@ -123,8 +123,6 @@ class EventStreamHandler:
|
|||||||
events,
|
events,
|
||||||
time_now,
|
time_now,
|
||||||
as_client_event=as_client_event,
|
as_client_event=as_client_event,
|
||||||
# Don't bundle aggregations as this is a deprecated API.
|
|
||||||
bundle_aggregations=False,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
chunk = {
|
chunk = {
|
||||||
|
@ -173,8 +173,6 @@ class InitialSyncHandler:
|
|||||||
d["invite"] = await self._event_serializer.serialize_event(
|
d["invite"] = await self._event_serializer.serialize_event(
|
||||||
invite_event,
|
invite_event,
|
||||||
time_now,
|
time_now,
|
||||||
# Don't bundle aggregations as this is a deprecated API.
|
|
||||||
bundle_aggregations=False,
|
|
||||||
as_client_event=as_client_event,
|
as_client_event=as_client_event,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -227,8 +225,6 @@ class InitialSyncHandler:
|
|||||||
await self._event_serializer.serialize_events(
|
await self._event_serializer.serialize_events(
|
||||||
messages,
|
messages,
|
||||||
time_now=time_now,
|
time_now=time_now,
|
||||||
# Don't bundle aggregations as this is a deprecated API.
|
|
||||||
bundle_aggregations=False,
|
|
||||||
as_client_event=as_client_event,
|
as_client_event=as_client_event,
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
@ -239,8 +235,6 @@ class InitialSyncHandler:
|
|||||||
d["state"] = await self._event_serializer.serialize_events(
|
d["state"] = await self._event_serializer.serialize_events(
|
||||||
current_state.values(),
|
current_state.values(),
|
||||||
time_now=time_now,
|
time_now=time_now,
|
||||||
# Don't bundle aggregations as this is a deprecated API.
|
|
||||||
bundle_aggregations=False,
|
|
||||||
as_client_event=as_client_event,
|
as_client_event=as_client_event,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -382,9 +376,7 @@ class InitialSyncHandler:
|
|||||||
"messages": {
|
"messages": {
|
||||||
"chunk": (
|
"chunk": (
|
||||||
# Don't bundle aggregations as this is a deprecated API.
|
# Don't bundle aggregations as this is a deprecated API.
|
||||||
await self._event_serializer.serialize_events(
|
await self._event_serializer.serialize_events(messages, time_now)
|
||||||
messages, time_now, bundle_aggregations=False
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"start": await start_token.to_string(self.store),
|
"start": await start_token.to_string(self.store),
|
||||||
"end": await end_token.to_string(self.store),
|
"end": await end_token.to_string(self.store),
|
||||||
@ -392,7 +384,7 @@ class InitialSyncHandler:
|
|||||||
"state": (
|
"state": (
|
||||||
# Don't bundle aggregations as this is a deprecated API.
|
# Don't bundle aggregations as this is a deprecated API.
|
||||||
await self._event_serializer.serialize_events(
|
await self._event_serializer.serialize_events(
|
||||||
room_state.values(), time_now, bundle_aggregations=False
|
room_state.values(), time_now
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
"presence": [],
|
"presence": [],
|
||||||
@ -413,7 +405,7 @@ class InitialSyncHandler:
|
|||||||
time_now = self.clock.time_msec()
|
time_now = self.clock.time_msec()
|
||||||
# Don't bundle aggregations as this is a deprecated API.
|
# Don't bundle aggregations as this is a deprecated API.
|
||||||
state = await self._event_serializer.serialize_events(
|
state = await self._event_serializer.serialize_events(
|
||||||
current_state.values(), time_now, bundle_aggregations=False
|
current_state.values(), time_now
|
||||||
)
|
)
|
||||||
|
|
||||||
now_token = self.hs.get_event_sources().get_current_token()
|
now_token = self.hs.get_event_sources().get_current_token()
|
||||||
@ -488,9 +480,7 @@ class InitialSyncHandler:
|
|||||||
"messages": {
|
"messages": {
|
||||||
"chunk": (
|
"chunk": (
|
||||||
# Don't bundle aggregations as this is a deprecated API.
|
# Don't bundle aggregations as this is a deprecated API.
|
||||||
await self._event_serializer.serialize_events(
|
await self._event_serializer.serialize_events(messages, time_now)
|
||||||
messages, time_now, bundle_aggregations=False
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
"start": await start_token.to_string(self.store),
|
"start": await start_token.to_string(self.store),
|
||||||
"end": await end_token.to_string(self.store),
|
"end": await end_token.to_string(self.store),
|
||||||
|
@ -246,7 +246,9 @@ class MessageHandler:
|
|||||||
room_state = room_state_events[membership_event_id]
|
room_state = room_state_events[membership_event_id]
|
||||||
|
|
||||||
now = self.clock.time_msec()
|
now = self.clock.time_msec()
|
||||||
events = await self._event_serializer.serialize_events(room_state.values(), now)
|
events = await self._event_serializer.serialize_events(
|
||||||
|
room_state.values(), now, bundle_aggregations=True
|
||||||
|
)
|
||||||
return events
|
return events
|
||||||
|
|
||||||
async def get_joined_members(self, requester: Requester, room_id: str) -> dict:
|
async def get_joined_members(self, requester: Requester, room_id: str) -> dict:
|
||||||
|
@ -542,7 +542,10 @@ class PaginationHandler:
|
|||||||
chunk = {
|
chunk = {
|
||||||
"chunk": (
|
"chunk": (
|
||||||
await self._event_serializer.serialize_events(
|
await self._event_serializer.serialize_events(
|
||||||
events, time_now, as_client_event=as_client_event
|
events,
|
||||||
|
time_now,
|
||||||
|
bundle_aggregations=True,
|
||||||
|
as_client_event=as_client_event,
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
"start": await from_token.to_string(self.store),
|
"start": await from_token.to_string(self.store),
|
||||||
|
@ -745,13 +745,19 @@ class RoomEventContextServlet(RestServlet):
|
|||||||
|
|
||||||
time_now = self.clock.time_msec()
|
time_now = self.clock.time_msec()
|
||||||
results["events_before"] = await self._event_serializer.serialize_events(
|
results["events_before"] = await self._event_serializer.serialize_events(
|
||||||
results["events_before"], time_now
|
results["events_before"],
|
||||||
|
time_now,
|
||||||
|
bundle_aggregations=True,
|
||||||
)
|
)
|
||||||
results["event"] = await self._event_serializer.serialize_event(
|
results["event"] = await self._event_serializer.serialize_event(
|
||||||
results["event"], time_now
|
results["event"],
|
||||||
|
time_now,
|
||||||
|
bundle_aggregations=True,
|
||||||
)
|
)
|
||||||
results["events_after"] = await self._event_serializer.serialize_events(
|
results["events_after"] = await self._event_serializer.serialize_events(
|
||||||
results["events_after"], time_now
|
results["events_after"],
|
||||||
|
time_now,
|
||||||
|
bundle_aggregations=True,
|
||||||
)
|
)
|
||||||
results["state"] = await self._event_serializer.serialize_events(
|
results["state"] = await self._event_serializer.serialize_events(
|
||||||
results["state"], time_now
|
results["state"], time_now
|
||||||
|
@ -232,7 +232,9 @@ class RelationPaginationServlet(RestServlet):
|
|||||||
)
|
)
|
||||||
# The relations returned for the requested event do include their
|
# The relations returned for the requested event do include their
|
||||||
# bundled aggregations.
|
# bundled aggregations.
|
||||||
serialized_events = await self._event_serializer.serialize_events(events, now)
|
serialized_events = await self._event_serializer.serialize_events(
|
||||||
|
events, now, bundle_aggregations=True
|
||||||
|
)
|
||||||
|
|
||||||
return_value = pagination_chunk.to_dict()
|
return_value = pagination_chunk.to_dict()
|
||||||
return_value["chunk"] = serialized_events
|
return_value["chunk"] = serialized_events
|
||||||
|
@ -662,7 +662,9 @@ class RoomEventServlet(RestServlet):
|
|||||||
|
|
||||||
time_now = self.clock.time_msec()
|
time_now = self.clock.time_msec()
|
||||||
if event:
|
if event:
|
||||||
event_dict = await self._event_serializer.serialize_event(event, time_now)
|
event_dict = await self._event_serializer.serialize_event(
|
||||||
|
event, time_now, bundle_aggregations=True
|
||||||
|
)
|
||||||
return 200, event_dict
|
return 200, event_dict
|
||||||
|
|
||||||
raise SynapseError(404, "Event not found.", errcode=Codes.NOT_FOUND)
|
raise SynapseError(404, "Event not found.", errcode=Codes.NOT_FOUND)
|
||||||
@ -707,13 +709,13 @@ class RoomEventContextServlet(RestServlet):
|
|||||||
|
|
||||||
time_now = self.clock.time_msec()
|
time_now = self.clock.time_msec()
|
||||||
results["events_before"] = await self._event_serializer.serialize_events(
|
results["events_before"] = await self._event_serializer.serialize_events(
|
||||||
results["events_before"], time_now
|
results["events_before"], time_now, bundle_aggregations=True
|
||||||
)
|
)
|
||||||
results["event"] = await self._event_serializer.serialize_event(
|
results["event"] = await self._event_serializer.serialize_event(
|
||||||
results["event"], time_now
|
results["event"], time_now, bundle_aggregations=True
|
||||||
)
|
)
|
||||||
results["events_after"] = await self._event_serializer.serialize_events(
|
results["events_after"] = await self._event_serializer.serialize_events(
|
||||||
results["events_after"], time_now
|
results["events_after"], time_now, bundle_aggregations=True
|
||||||
)
|
)
|
||||||
results["state"] = await self._event_serializer.serialize_events(
|
results["state"] = await self._event_serializer.serialize_events(
|
||||||
results["state"], time_now
|
results["state"], time_now
|
||||||
|
Loading…
Reference in New Issue
Block a user