This repository was archived by the owner on Apr 26, 2024. It is now read-only.
File tree 4 files changed +19
-19
lines changed
4 files changed +19
-19
lines changed Original file line number Diff line number Diff line change
1
+ Include the bundled aggregations in the `/sync` response.
Original file line number Diff line number Diff line change @@ -102,6 +102,9 @@ class TimelineBatch:
102
102
prev_batch : StreamToken
103
103
events : List [EventBase ]
104
104
limited : bool
105
+ # A mapping of event ID to the bundled aggregations for the above events.
106
+ # This is only calculated if limited is true.
107
+ bundled_aggregations : Optional [Dict [str , Dict [str , Any ]]] = None
105
108
106
109
def __bool__ (self ) -> bool :
107
110
"""Make the result appear empty if there are no updates. This is used
@@ -634,10 +637,17 @@ async def _load_filtered_recents(
634
637
635
638
prev_batch_token = now_token .copy_and_replace ("room_key" , room_key )
636
639
640
+ # Don't bother to bundle aggregations if the timeline is unlimited,
641
+ # as clients will have all the necessary information.
642
+ bundled_aggregations = None
643
+ if limited :
644
+ bundled_aggregations = await self .store .get_bundled_aggregations (recents )
645
+
637
646
return TimelineBatch (
638
647
events = recents ,
639
648
prev_batch = prev_batch_token ,
640
649
limited = limited or newly_joined_room ,
650
+ bundled_aggregations = bundled_aggregations ,
641
651
)
642
652
643
653
async def get_state_after_event (
Original file line number Diff line number Diff line change @@ -554,20 +554,9 @@ def serialize(
554
554
)
555
555
556
556
serialized_state = serialize (state_events )
557
- # Don't bother to bundle aggregations if the timeline is unlimited,
558
- # as clients will have all the necessary information.
559
- # bundle_aggregations=room.timeline.limited,
560
- #
561
- # richvdh 2021-12-15: disable this temporarily as it has too high an
562
- # overhead for initialsyncs. We need to figure out a way that the
563
- # bundling can be done *before* the events are stored in the
564
- # SyncResponseCache so that this part can be synchronous.
565
- #
566
- # Ensure to re-enable the test at tests/rest/client/test_relations.py::RelationsTestCase.test_bundled_aggregations.
567
- # if room.timeline.limited:
568
- # aggregations = await self.store.get_bundled_aggregations(timeline_events)
569
- aggregations = None
570
- serialized_timeline = serialize (timeline_events , aggregations )
557
+ serialized_timeline = serialize (
558
+ timeline_events , room .timeline .bundled_aggregations
559
+ )
571
560
572
561
account_data = room .account_data
573
562
Original file line number Diff line number Diff line change @@ -577,11 +577,11 @@ def _find_and_assert_event(events):
577
577
assert_bundle (channel .json_body ["event" ]["unsigned" ].get ("m.relations" ))
578
578
579
579
# Request sync.
580
- # channel = self.make_request("GET", "/sync", access_token=self.user_token)
581
- # self.assertEquals(200, channel.code, channel.json_body)
582
- # room_timeline = channel.json_body["rooms"]["join"][self.room]["timeline"]
583
- # self.assertTrue(room_timeline["limited"])
584
- # _find_and_assert_event(room_timeline["events"])
580
+ channel = self .make_request ("GET" , "/sync" , access_token = self .user_token )
581
+ self .assertEquals (200 , channel .code , channel .json_body )
582
+ room_timeline = channel .json_body ["rooms" ]["join" ][self .room ]["timeline" ]
583
+ self .assertTrue (room_timeline ["limited" ])
584
+ _find_and_assert_event (room_timeline ["events" ])
585
585
586
586
# Note that /relations is tested separately in test_aggregation_get_event_for_thread
587
587
# since it needs different data configured.
You can’t perform that action at this time.
0 commit comments