mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-12-25 10:19:22 -05:00
Support sending no state_events_at_start
in the MSC2716 /batch_send
endpoint (#11188)
As brought up by @tulir, https://matrix.to/#/!SBYNQlpqkwJzFIdzxI:nevarro.space/$Gwnb2ZvXHc3poYXuBhho0cmoYq4KJ11Jh3m5s8kjNOM?via=nevarro.space&via=beeper.com&via=matrix.org This use case only works if the user is already joined in the current room state at the given `?prev_event_id`
This commit is contained in:
parent
6250b95efe
commit
da0040785e
1
changelog.d/11188.bugfix
Normal file
1
changelog.d/11188.bugfix
Normal file
@ -0,0 +1 @@
|
|||||||
|
Allow an empty list of `state_events_at_start` to be sent when using the [MSC2716](https://github.com/matrix-org/matrix-doc/pull/2716) `/batch_send` endpoint and the author of the historical messages is already part of the current room state at the given `?prev_event_id`.
|
@ -131,20 +131,22 @@ class RoomBatchSendEventRestServlet(RestServlet):
|
|||||||
prev_event_ids_from_query
|
prev_event_ids_from_query
|
||||||
)
|
)
|
||||||
|
|
||||||
|
state_event_ids_at_start = []
|
||||||
# Create and persist all of the state events that float off on their own
|
# Create and persist all of the state events that float off on their own
|
||||||
# before the batch. These will most likely be all of the invite/member
|
# before the batch. These will most likely be all of the invite/member
|
||||||
# state events used to auth the upcoming historical messages.
|
# state events used to auth the upcoming historical messages.
|
||||||
state_event_ids_at_start = (
|
if body["state_events_at_start"]:
|
||||||
await self.room_batch_handler.persist_state_events_at_start(
|
state_event_ids_at_start = (
|
||||||
state_events_at_start=body["state_events_at_start"],
|
await self.room_batch_handler.persist_state_events_at_start(
|
||||||
room_id=room_id,
|
state_events_at_start=body["state_events_at_start"],
|
||||||
initial_auth_event_ids=auth_event_ids,
|
room_id=room_id,
|
||||||
app_service_requester=requester,
|
initial_auth_event_ids=auth_event_ids,
|
||||||
|
app_service_requester=requester,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
# Update our ongoing auth event ID list with all of the new state we
|
||||||
# Update our ongoing auth event ID list with all of the new state we
|
# just created
|
||||||
# just created
|
auth_event_ids.extend(state_event_ids_at_start)
|
||||||
auth_event_ids.extend(state_event_ids_at_start)
|
|
||||||
|
|
||||||
inherited_depth = await self.room_batch_handler.inherit_depth_from_prev_ids(
|
inherited_depth = await self.room_batch_handler.inherit_depth_from_prev_ids(
|
||||||
prev_event_ids_from_query
|
prev_event_ids_from_query
|
||||||
@ -197,8 +199,11 @@ class RoomBatchSendEventRestServlet(RestServlet):
|
|||||||
|
|
||||||
# Also connect the historical event chain to the end of the floating
|
# Also connect the historical event chain to the end of the floating
|
||||||
# state chain, which causes the HS to ask for the state at the start of
|
# state chain, which causes the HS to ask for the state at the start of
|
||||||
# the batch later.
|
# the batch later. If there is no state chain to connect to, just make
|
||||||
prev_event_ids = [state_event_ids_at_start[-1]]
|
# the insertion event float itself.
|
||||||
|
prev_event_ids = []
|
||||||
|
if len(state_event_ids_at_start):
|
||||||
|
prev_event_ids = [state_event_ids_at_start[-1]]
|
||||||
|
|
||||||
# Create and persist all of the historical events as well as insertion
|
# Create and persist all of the historical events as well as insertion
|
||||||
# and batch meta events to make the batch navigable in the DAG.
|
# and batch meta events to make the batch navigable in the DAG.
|
||||||
|
Loading…
Reference in New Issue
Block a user