@@ -153,6 +153,7 @@ async def persist_state_events_at_start(
153153 self ,
154154 state_events_at_start : List [JsonDict ],
155155 room_id : str ,
156+ initial_prev_event_ids : List [str ],
156157 initial_state_event_ids : List [str ],
157158 app_service_requester : Requester ,
158159 ) -> List [str ]:
@@ -178,10 +179,8 @@ async def persist_state_events_at_start(
178179 state_event_ids_at_start = []
179180 state_event_ids = initial_state_event_ids .copy ()
180181
181- # Make the state events float off on their own by specifying no
182- # prev_events for the first one in the chain so we don't have a bunch of
183- # `@mxid joined the room` noise between each batch.
184- prev_event_ids_for_state_chain : List [str ] = []
182+ # TODO: Here
183+ prev_event_ids_for_state_chain : List [str ] = initial_prev_event_ids
185184
186185 for index , state_event in enumerate (state_events_at_start ):
187186 assert_params_in_dict (
@@ -269,6 +268,7 @@ async def persist_historical_events(
269268 events_to_create : List [JsonDict ],
270269 room_id : str ,
271270 inherited_depth : int ,
271+ state_chain_event_id_to_connect_to : str ,
272272 initial_state_event_ids : List [str ],
273273 app_service_requester : Requester ,
274274 ) -> List [str ]:
@@ -301,10 +301,8 @@ async def persist_historical_events(
301301 # We expect the last event in a historical batch to be an batch event
302302 assert events_to_create [- 1 ]["type" ] == EventTypes .MSC2716_BATCH
303303
304- # Make the historical event chain float off on its own by specifying no
305- # prev_events for the first event in the chain which causes the HS to
306- # ask for the state at the start of the batch later.
307- prev_event_ids : List [str ] = []
304+ # TODO: Here
305+ prev_event_ids : List [str ] = [state_chain_event_id_to_connect_to ]
308306
309307 event_ids = []
310308 events_to_persist = []
@@ -390,6 +388,7 @@ async def handle_batch_of_events(
390388 events_to_create : List [JsonDict ],
391389 room_id : str ,
392390 batch_id_to_connect_to : str ,
391+ state_chain_event_id_to_connect_to : str ,
393392 inherited_depth : int ,
394393 initial_state_event_ids : List [str ],
395394 app_service_requester : Requester ,
@@ -458,6 +457,7 @@ async def handle_batch_of_events(
458457 events_to_create = events_to_create ,
459458 room_id = room_id ,
460459 inherited_depth = inherited_depth ,
460+ state_chain_event_id_to_connect_to = state_chain_event_id_to_connect_to ,
461461 initial_state_event_ids = initial_state_event_ids ,
462462 app_service_requester = app_service_requester ,
463463 )
0 commit comments