@@ -155,8 +155,9 @@ def __init__(self, hs):
155155 self ._device_list_updater = hs .get_device_handler ().device_list_updater
156156 self ._maybe_store_room_on_invite = self .store .maybe_store_room_on_invite
157157
158- # When joining a room we need to queue any events for that room up
159- self .room_queues = {}
158+ # When joining a room we need to queue any events for that room up.
159+ # For each room, a list of (pdu, origin) tuples.
160+ self .room_queues = {} # type: Dict[str, List[Tuple[EventBase, str]]]
160161 self ._room_pdu_linearizer = Linearizer ("fed_room_pdu" )
161162
162163 self .third_party_event_rules = hs .get_third_party_event_rules ()
@@ -817,6 +818,9 @@ async def backfill(self, dest, room_id, limit, extremities):
817818 dest , room_id , limit = limit , extremities = extremities
818819 )
819820
821+ if not events :
822+ return []
823+
820824 # ideally we'd sanity check the events here for excess prev_events etc,
821825 # but it's hard to reject events at this point without completely
822826 # breaking backfill in the same way that it is currently broken by
@@ -2174,10 +2178,10 @@ async def _check_for_soft_fail(
21742178 # given state at the event. This should correctly handle cases
21752179 # like bans, especially with state res v2.
21762180
2177- state_sets = await self .state_store .get_state_groups (
2181+ state_sets_d = await self .state_store .get_state_groups (
21782182 event .room_id , extrem_ids
21792183 )
2180- state_sets = list (state_sets .values ())
2184+ state_sets = list (state_sets_d .values ()) # type: List[Iterable[EventBase]]
21812185 state_sets .append (state )
21822186 current_states = await self .state_handler .resolve_events (
21832187 room_version , state_sets , event
@@ -2968,6 +2972,7 @@ async def persist_events_and_notify(
29682972 )
29692973 return result ["max_stream_id" ]
29702974 else :
2975+ assert self .storage .persistence
29712976 max_stream_token = await self .storage .persistence .persist_events (
29722977 event_and_contexts , backfilled = backfilled
29732978 )
0 commit comments