@@ -1194,10 +1194,17 @@ async def prep(event: EventBase) -> Optional[Tuple[EventBase, EventContext]]:
1194
1194
auth = {}
1195
1195
for auth_event_id in event .auth_event_ids ():
1196
1196
ae = persisted_events .get (auth_event_id )
1197
- if ae :
1198
- auth [(ae .type , ae .state_key )] = ae
1199
- else :
1200
- logger .info ("Missing auth event %s" , auth_event_id )
1197
+ if not ae :
1198
+ logger .warning (
1199
+ "Event %s relies on auth_event %s, which could not be found." ,
1200
+ event ,
1201
+ auth_event_id ,
1202
+ )
1203
+ # the fact we can't find the auth event doesn't mean it doesn't
1204
+ # exist, which means it is premature to reject `event`. Instead we
1205
+ # just ignore it for now.
1206
+ return None
1207
+ auth [(ae .type , ae .state_key )] = ae
1201
1208
1202
1209
context = EventContext .for_outlier ()
1203
1210
context = await self ._check_event_auth (
@@ -1208,8 +1215,10 @@ async def prep(event: EventBase) -> Optional[Tuple[EventBase, EventContext]]:
1208
1215
)
1209
1216
return event , context
1210
1217
1211
- events_to_persist = await yieldable_gather_results (prep , fetched_events )
1212
- await self .persist_events_and_notify (room_id , events_to_persist )
1218
+ events_to_persist = (
1219
+ x for x in await yieldable_gather_results (prep , fetched_events ) if x
1220
+ )
1221
+ await self .persist_events_and_notify (room_id , tuple (events_to_persist ))
1213
1222
1214
1223
async def _check_event_auth (
1215
1224
self ,
@@ -1235,8 +1244,7 @@ async def _check_event_auth(
1235
1244
1236
1245
claimed_auth_event_map:
1237
1246
A map of (type, state_key) => event for the event's claimed auth_events.
1238
- Possibly incomplete, and possibly including events that are not yet
1239
- persisted, or authed, or in the right room.
1247
+ Possibly including events that were rejected, or are in the wrong room.
1240
1248
1241
1249
Only populated when populating outliers.
1242
1250
0 commit comments