@@ -326,8 +326,32 @@ async def on_receive_pdu(
326
326
if not missing_prevs :
327
327
logger .info ("Found all missing prev_events" )
328
328
329
- if missing_prevs :
330
- # We've still not been able to get all of the prev_events for this event.
329
+ if missing_prevs :
330
+ # since this event was pushed to us, it is possible for it to
331
+ # become the only forward-extremity in the room, and we would then
332
+ # trust its state to be the state for the whole room. This is very
333
+ # bad. Further, if the event was pushed to us, there is no excuse
334
+ # for us not to have all the prev_events. (XXX: apart from
335
+ # min_depth?)
336
+ #
337
+ # We therefore reject any such events.
338
+ logger .warning (
339
+ "Rejecting: failed to fetch %d prev events: %s" ,
340
+ len (missing_prevs ),
341
+ shortstr (missing_prevs ),
342
+ )
343
+ raise FederationError (
344
+ "ERROR" ,
345
+ 403 ,
346
+ (
347
+ "Your server isn't divulging details about prev_events "
348
+ "referenced in this event."
349
+ ),
350
+ affected = pdu .event_id ,
351
+ )
352
+
353
+ else :
354
+ # We don't have all of the prev_events for this event.
331
355
#
332
356
# In this case, we need to fall back to asking another server in the
333
357
# federation for the state at this event. That's ok provided we then
@@ -336,37 +360,15 @@ async def on_receive_pdu(
336
360
# withholding its prev_events, and declaring yourself to be an admin in
337
361
# the subsequent state request).
338
362
#
339
- # Now, if we're pulling this event as a missing prev_event, then clearly
363
+ # Since we're pulling this event as a missing prev_event, then clearly
340
364
# this event is not going to become the only forward-extremity and we are
341
365
# guaranteed to resolve its state against our existing forward
342
366
# extremities, so that should be fine.
343
367
#
344
- # On the other hand, if this event was pushed to us, it is possible for
345
- # it to become the only forward-extremity in the room, and we would then
346
- # trust its state to be the state for the whole room. This is very bad.
347
- # Further, if the event was pushed to us, there is no excuse for us not to
348
- # have all the prev_events. We therefore reject any such events.
349
- #
350
368
# XXX this really feels like it could/should be merged with the above,
351
369
# but there is an interaction with min_depth that I'm not really
352
370
# following.
353
371
354
- if sent_to_us_directly :
355
- logger .warning (
356
- "Rejecting: failed to fetch %d prev events: %s" ,
357
- len (missing_prevs ),
358
- shortstr (missing_prevs ),
359
- )
360
- raise FederationError (
361
- "ERROR" ,
362
- 403 ,
363
- (
364
- "Your server isn't divulging details about prev_events "
365
- "referenced in this event."
366
- ),
367
- affected = pdu .event_id ,
368
- )
369
-
370
372
logger .info (
371
373
"Event %s is missing prev_events %s: calculating state for a "
372
374
"backwards extremity" ,
0 commit comments