@@ -2210,7 +2210,36 @@ async def _send_dummy_events_to_fill_extremities(self) -> None:
22102210 now = self .clock .time_msec ()
22112211 self ._rooms_to_exclude_from_dummy_event_insertion [room_id ] = now
22122212
2213- async def _send_dummy_event_for_room (self , room_id : str ) -> bool :
2213+ async def _send_dummy_events_to_patch_room (self , room_id : str ) -> None :
2214+ """
2215+ Send a dummy event into this room to patch in a missed forward extremity.
2216+ This should only be triggered during a remote join if there was a forward
2217+ extremity that occurred during the make_join/send_join handshake.
2218+ """
2219+ async with self ._worker_lock_handler .acquire_read_write_lock (
2220+ NEW_EVENT_DURING_PURGE_LOCK_NAME , room_id , write = False
2221+ ):
2222+ dummy_event_sent = await self ._send_dummy_event_for_room (
2223+ room_id , proactively_send = True
2224+ )
2225+
2226+ if not dummy_event_sent :
2227+ # Did not find a valid user in the room, so remove from future attempts
2228+ # Exclusion is time limited, so the room will be rechecked in the future
2229+ # dependent on _DUMMY_EVENT_ROOM_EXCLUSION_EXPIRY
2230+ logger .info (
2231+ "Failed to send dummy event into room %s. Will exclude it from "
2232+ "future attempts until cache expires" ,
2233+ room_id ,
2234+ )
2235+ # This mapping is room_id -> time of last attempt(in ms)
2236+ self ._rooms_to_exclude_from_dummy_event_insertion [room_id ] = (
2237+ self .clock .time_msec ()
2238+ )
2239+
2240+ async def _send_dummy_event_for_room (
2241+ self , room_id : str , proactively_send : bool = False
2242+ ) -> bool :
22142243 """Attempt to send a dummy event for the given room.
22152244
22162245 Args:
@@ -2242,8 +2271,7 @@ async def _send_dummy_event_for_room(self, room_id: str) -> bool:
22422271 },
22432272 )
22442273 context = await unpersisted_context .persist (event )
2245-
2246- event .internal_metadata .proactively_send = False
2274+ event .internal_metadata .proactively_send = proactively_send
22472275
22482276 # Since this is a dummy-event it is OK if it is sent by a
22492277 # shadow-banned user.
0 commit comments