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

Return a 404 from /state for an outlier #12087

Merged
merged 8 commits into from
Mar 21, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions synapse/handlers/federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -963,14 +963,17 @@ async def get_state_ids_for_pdu(self, room_id: str, event_id: str) -> List[str]:

state_map = next(iter(state_groups.values()))

if event.is_state():
# Get previous state
# we need the state *before* event.
state_key = event.get_state_key()
if (
state_key is not None
and state_map.get((event.type, state_key)) == event.event_id
richvdh marked this conversation as resolved.
Show resolved Hide resolved
):
if "replaces_state" in event.unsigned:
prev_id = event.unsigned["replaces_state"]
if prev_id != event.event_id:
state_map[(event.type, event.state_key)] = prev_id
state_map[(event.type, state_key)] = prev_id
else:
state_map.pop((event.type, event.state_key), None)
del state_map[(event.type, state_key)]

return list(state_map.values())

Expand Down