Rename /batch_send query parameter from ?prev_event to more obvious usage with ?prev_event_id (MSC2716) (#10839)

As mentioned in https://github.com/matrix-org/matrix-doc/pull/2716#discussion_r705872887
and https://github.com/matrix-org/synapse/issues/10737
This commit is contained in:
Eric Eastwood 2021-09-21 08:10:01 -05:00 committed by GitHub
parent 706b0e41a1
commit ee557b5375
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 7 deletions

1
changelog.d/10839.misc Normal file
View File

@ -0,0 +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`.

View File

@ -61,7 +61,7 @@ class RoomBatchSendEventRestServlet(RestServlet):
some messages, you can only insert older ones after that. some messages, you can only insert older ones after that.
tldr; Insert chunks from your most recent history -> oldest history. tldr; Insert chunks from your most recent history -> oldest history.
POST /_matrix/client/unstable/org.matrix.msc2716/rooms/<roomID>/batch_send?prev_event=<eventID>&chunk_id=<chunkID> POST /_matrix/client/unstable/org.matrix.msc2716/rooms/<roomID>/batch_send?prev_event_id=<eventID>&chunk_id=<chunkID>
{ {
"events": [ ... ], "events": [ ... ],
"state_events_at_start": [ ... ] "state_events_at_start": [ ... ]
@ -188,24 +188,26 @@ class RoomBatchSendEventRestServlet(RestServlet):
assert_params_in_dict(body, ["state_events_at_start", "events"]) assert_params_in_dict(body, ["state_events_at_start", "events"])
assert request.args is not None assert request.args is not None
prev_events_from_query = parse_strings_from_args(request.args, "prev_event") prev_event_ids_from_query = parse_strings_from_args(
request.args, "prev_event_id"
)
chunk_id_from_query = parse_string(request, "chunk_id") chunk_id_from_query = parse_string(request, "chunk_id")
if prev_events_from_query is None: if prev_event_ids_from_query is None:
raise SynapseError( raise SynapseError(
HTTPStatus.BAD_REQUEST, HTTPStatus.BAD_REQUEST,
"prev_event query parameter is required when inserting historical messages back in time", "prev_event query parameter is required when inserting historical messages back in time",
errcode=Codes.MISSING_PARAM, errcode=Codes.MISSING_PARAM,
) )
# For the event we are inserting next to (`prev_events_from_query`), # For the event we are inserting next to (`prev_event_ids_from_query`),
# find the most recent auth events (derived from state events) that # find the most recent auth events (derived from state events) that
# allowed that message to be sent. We will use that as a base # allowed that message to be sent. We will use that as a base
# to auth our historical messages against. # to auth our historical messages against.
( (
most_recent_prev_event_id, most_recent_prev_event_id,
_, _,
) = await self.store.get_max_depth_of(prev_events_from_query) ) = await self.store.get_max_depth_of(prev_event_ids_from_query)
# mapping from (type, state_key) -> state_event_id # mapping from (type, state_key) -> state_event_id
prev_state_map = await self.state_store.get_state_ids_for_event( prev_state_map = await self.state_store.get_state_ids_for_event(
most_recent_prev_event_id most_recent_prev_event_id
@ -286,7 +288,7 @@ class RoomBatchSendEventRestServlet(RestServlet):
events_to_create = body["events"] events_to_create = body["events"]
inherited_depth = await self._inherit_depth_from_prev_ids( inherited_depth = await self._inherit_depth_from_prev_ids(
prev_events_from_query prev_event_ids_from_query
) )
# Figure out which chunk to connect to. If they passed in # Figure out which chunk to connect to. If they passed in
@ -321,7 +323,7 @@ class RoomBatchSendEventRestServlet(RestServlet):
# an insertion event), in which case we just create a new insertion event # an insertion event), in which case we just create a new insertion event
# that can then get pointed to by a "marker" event later. # that can then get pointed to by a "marker" event later.
else: else:
prev_event_ids = prev_events_from_query prev_event_ids = prev_event_ids_from_query
base_insertion_event_dict = self._create_insertion_event_dict( base_insertion_event_dict = self._create_insertion_event_dict(
sender=requester.user.to_string(), sender=requester.user.to_string(),