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

Commit

Permalink
Only remove event if it was in the result in the first place.
Browse files Browse the repository at this point in the history
  • Loading branch information
richvdh committed Feb 25, 2022
1 parent 9223f4f commit 5fdc7c7
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions synapse/handlers/federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1008,14 +1008,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
):
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

0 comments on commit 5fdc7c7

Please sign in to comment.