Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Add Erik's explanation of extra event checks
Browse files Browse the repository at this point in the history
  • Loading branch information
MadLittleMods committed Aug 3, 2021
1 parent 71c2f05 commit b832264
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions synapse/handlers/federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,12 @@ async def on_receive_pdu(

state = None

# Get missing pdus if necessary.
# We don't need to worry about outliers because TODO!
# Check that the event passes auth based on the state at the event. This is
# done for events that are to be added to the timeline (non-outliers).
#
# Get missing pdus if necessary:
# - Fetching any missing prev events to fill in gaps in the graph
# - Fetching state if we have a hole in the graph
if not pdu.internal_metadata.is_outlier():
# We only backfill backwards to the min depth.
min_depth = await self.get_min_depth_for_context(pdu.room_id)
Expand Down Expand Up @@ -434,6 +438,13 @@ async def on_receive_pdu(
affected=event_id,
)

# A second round of checks for all events. Check that the event passes auth
# based on `auth_events`, this allows us to assert that the event would
# have been allowed at some point. If an event passes this check its OK
# for it to be used as part of a returned `/state` request, as either
# a) we received the event as part of the original join and so trust it, or
# b) we'll do a state resolution with existing state before it becomes
# part of the "current state", which adds more protection.
await self._process_received_pdu(origin, pdu, state=state)

async def _get_missing_events_for_pdu(
Expand Down

0 comments on commit b832264

Please sign in to comment.