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

Commit 5e289f1

Browse files
committed
Only remove event if it was in the result in the first place.
1 parent 9babf34 commit 5e289f1

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

synapse/handlers/federation.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,14 +1017,17 @@ async def get_state_ids_for_pdu(self, room_id: str, event_id: str) -> List[str]:
10171017

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

1020-
if event.is_state():
1021-
# Get previous state
1020+
# we need the state *before* event.
1021+
state_key = event.get_state_key()
1022+
if (
1023+
state_key is not None
1024+
and state_map.get((event.type, state_key)) == event.event_id
1025+
):
10221026
if "replaces_state" in event.unsigned:
10231027
prev_id = event.unsigned["replaces_state"]
1024-
if prev_id != event.event_id:
1025-
state_map[(event.type, event.state_key)] = prev_id
1028+
state_map[(event.type, state_key)] = prev_id
10261029
else:
1027-
state_map.pop((event.type, event.state_key), None)
1030+
del state_map[(event.type, state_key)]
10281031

10291032
return list(state_map.values())
10301033

0 commit comments

Comments
 (0)