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

Only return state events that the AS passed in via state_events_at_start (MSC2716) #10552

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions changelog.d/10552.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update `/batch_send` endpoint to only return `state_events` created by the `state_events_from_before` passed in.
4 changes: 3 additions & 1 deletion synapse/rest/client/v1/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ async def on_POST(self, request, room_id):
prev_state_ids = list(prev_state_map.values())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just realised that we should probably not be adding this class to v1/room.py, but instead somewhere in v2/. If only someone had reviewed the PR that added this endpoint.................. 🤦

Copy link
Contributor Author

@MadLittleMods MadLittleMods Aug 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can switch it over in another PR 😁

/batch_send evolved from the normal /send API with the ?ts parameter in the same file so it was a natural resting place 😁

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#10576

auth_event_ids = prev_state_ids

state_events_at_start = []
for state_event in body["state_events_at_start"]:
assert_params_in_dict(
state_event, ["type", "origin_server_ts", "content", "sender"]
Expand Down Expand Up @@ -500,6 +501,7 @@ async def on_POST(self, request, room_id):
)
event_id = event.event_id

state_events_at_start.append(event_id)
auth_event_ids.append(event_id)

events_to_create = body["events"]
Expand Down Expand Up @@ -647,7 +649,7 @@ async def on_POST(self, request, room_id):
event_ids.append(base_insertion_event.event_id)

return 200, {
"state_events": auth_event_ids,
"state_events": state_events_at_start,
"events": event_ids,
"next_chunk_id": insertion_event["content"][
EventContentFields.MSC2716_NEXT_CHUNK_ID
Expand Down