@@ -214,7 +214,7 @@ async def on_receive_pdu(self, origin: str, pdu: EventBase) -> None:
214214
215215 if missing_prevs :
216216 # We only backfill backwards to the min depth.
217- min_depth = await self .get_min_depth_for_context (pdu .room_id )
217+ min_depth = await self ._store . get_min_depth (pdu .room_id )
218218 logger .debug ("min_depth: %d" , min_depth )
219219
220220 if min_depth is not None and pdu .depth > min_depth :
@@ -1696,16 +1696,27 @@ async def _run_push_actions_and_persist_event(
16961696 # persist_events_and_notify directly.)
16971697 assert not event .internal_metadata .outlier
16981698
1699- try :
1700- if (
1701- not backfilled
1702- and not context .rejected
1703- and (await self ._store .get_min_depth (event .room_id )) <= event .depth
1704- ):
1699+ if not backfilled and not context .rejected :
1700+ min_depth = await self ._store .get_min_depth (event .room_id )
1701+ if min_depth is None or min_depth > event .depth :
1702+ # XXX richvdh 2021/10/07: I don't really understand what this
1703+ # condition is doing. I think it's trying not to send pushes
1704+ # for events that predate our join - but that's not really what
1705+ # min_depth means, and anyway ancient events are a more general
1706+ # problem.
1707+ #
1708+ # for now I'm just going to log about it.
1709+ logger .info (
1710+ "Skipping push actions for old event with depth %s < %s" ,
1711+ event .depth ,
1712+ min_depth ,
1713+ )
1714+ else :
17051715 await self ._action_generator .handle_push_actions_for_event (
17061716 event , context
17071717 )
17081718
1719+ try :
17091720 await self .persist_events_and_notify (
17101721 event .room_id , [(event , context )], backfilled = backfilled
17111722 )
@@ -1837,6 +1848,3 @@ def _sanity_check_event(self, ev: EventBase) -> None:
18371848 len (ev .auth_event_ids ()),
18381849 )
18391850 raise SynapseError (HTTPStatus .BAD_REQUEST , "Too many auth_events" )
1840-
1841- async def get_min_depth_for_context (self , context : str ) -> int :
1842- return await self ._store .get_min_depth (context )
0 commit comments