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

Commit ee557b5

Browse files
Rename /batch_send query parameter from ?prev_event to more obvious usage with ?prev_event_id (MSC2716) (#10839)
As mentioned in matrix-org/matrix-spec-proposals#2716 (comment) and #10737
1 parent 706b0e4 commit ee557b5

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

changelog.d/10839.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Rename [MSC2716](https://github.com/matrix-org/matrix-doc/pull/2716) `/batch_send` query parameter from `?prev_event` to more obvious usage with `?prev_event_id`.

synapse/rest/client/room_batch.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class RoomBatchSendEventRestServlet(RestServlet):
6161
some messages, you can only insert older ones after that.
6262
tldr; Insert chunks from your most recent history -> oldest history.
6363
64-
POST /_matrix/client/unstable/org.matrix.msc2716/rooms/<roomID>/batch_send?prev_event=<eventID>&chunk_id=<chunkID>
64+
POST /_matrix/client/unstable/org.matrix.msc2716/rooms/<roomID>/batch_send?prev_event_id=<eventID>&chunk_id=<chunkID>
6565
{
6666
"events": [ ... ],
6767
"state_events_at_start": [ ... ]
@@ -188,24 +188,26 @@ async def on_POST(
188188
assert_params_in_dict(body, ["state_events_at_start", "events"])
189189

190190
assert request.args is not None
191-
prev_events_from_query = parse_strings_from_args(request.args, "prev_event")
191+
prev_event_ids_from_query = parse_strings_from_args(
192+
request.args, "prev_event_id"
193+
)
192194
chunk_id_from_query = parse_string(request, "chunk_id")
193195

194-
if prev_events_from_query is None:
196+
if prev_event_ids_from_query is None:
195197
raise SynapseError(
196198
HTTPStatus.BAD_REQUEST,
197199
"prev_event query parameter is required when inserting historical messages back in time",
198200
errcode=Codes.MISSING_PARAM,
199201
)
200202

201-
# For the event we are inserting next to (`prev_events_from_query`),
203+
# For the event we are inserting next to (`prev_event_ids_from_query`),
202204
# find the most recent auth events (derived from state events) that
203205
# allowed that message to be sent. We will use that as a base
204206
# to auth our historical messages against.
205207
(
206208
most_recent_prev_event_id,
207209
_,
208-
) = await self.store.get_max_depth_of(prev_events_from_query)
210+
) = await self.store.get_max_depth_of(prev_event_ids_from_query)
209211
# mapping from (type, state_key) -> state_event_id
210212
prev_state_map = await self.state_store.get_state_ids_for_event(
211213
most_recent_prev_event_id
@@ -286,7 +288,7 @@ async def on_POST(
286288
events_to_create = body["events"]
287289

288290
inherited_depth = await self._inherit_depth_from_prev_ids(
289-
prev_events_from_query
291+
prev_event_ids_from_query
290292
)
291293

292294
# Figure out which chunk to connect to. If they passed in
@@ -321,7 +323,7 @@ async def on_POST(
321323
# an insertion event), in which case we just create a new insertion event
322324
# that can then get pointed to by a "marker" event later.
323325
else:
324-
prev_event_ids = prev_events_from_query
326+
prev_event_ids = prev_event_ids_from_query
325327

326328
base_insertion_event_dict = self._create_insertion_event_dict(
327329
sender=requester.user.to_string(),

0 commit comments

Comments
 (0)