@@ -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 ()
@@ -814,6 +815,9 @@ async def backfill(self, dest, room_id, limit, extremities):
814815 dest , room_id , limit = limit , extremities = extremities
815816 )
816817
818+ if not events :
819+ return []
820+
817821 # ideally we'd sanity check the events here for excess prev_events etc,
818822 # but it's hard to reject events at this point without completely
819823 # breaking backfill in the same way that it is currently broken by
@@ -2164,10 +2168,10 @@ async def _check_for_soft_fail(
21642168 # given state at the event. This should correctly handle cases
21652169 # like bans, especially with state res v2.
21662170
2167- state_sets = await self .state_store .get_state_groups (
2171+ state_sets_d = await self .state_store .get_state_groups (
21682172 event .room_id , extrem_ids
21692173 )
2170- state_sets = list (state_sets .values ())
2174+ state_sets = list (state_sets_d .values ()) # type: List[Iterable[EventBase]]
21712175 state_sets .append (state )
21722176 current_states = await self .state_handler .resolve_events (
21732177 room_version , state_sets , event
@@ -2958,6 +2962,7 @@ async def persist_events_and_notify(
29582962 )
29592963 return result ["max_stream_id" ]
29602964 else :
2965+ assert self .storage .persistence
29612966 max_stream_token = await self .storage .persistence .persist_events (
29622967 event_and_contexts , backfilled = backfilled
29632968 )
0 commit comments