mirror of
https://github.com/element-hq/synapse.git
synced 2024-11-25 11:05:49 +03:00
Room batch: fix up handling of unknown prev_event_ids (#12316)
This commit is contained in:
parent
8a519f8abc
commit
1f32b90b0f
2 changed files with 14 additions and 8 deletions
1
changelog.d/12316.misc
Normal file
1
changelog.d/12316.misc
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Avoid trying to calculate the state at outlier events.
|
|
@ -123,6 +123,19 @@ class RoomBatchSendEventRestServlet(RestServlet):
|
||||||
errcode=Codes.INVALID_PARAM,
|
errcode=Codes.INVALID_PARAM,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Make sure that the prev_event_ids exist and aren't outliers - ie, they are
|
||||||
|
# regular parts of the room DAG where we know the state.
|
||||||
|
non_outlier_prev_events = await self.store.have_events_in_timeline(
|
||||||
|
prev_event_ids_from_query
|
||||||
|
)
|
||||||
|
for prev_event_id in prev_event_ids_from_query:
|
||||||
|
if prev_event_id not in non_outlier_prev_events:
|
||||||
|
raise SynapseError(
|
||||||
|
HTTPStatus.BAD_REQUEST,
|
||||||
|
"prev_event %s does not exist, or is an outlier" % (prev_event_id,),
|
||||||
|
errcode=Codes.INVALID_PARAM,
|
||||||
|
)
|
||||||
|
|
||||||
# For the event we are inserting next to (`prev_event_ids_from_query`),
|
# For the event we are inserting next to (`prev_event_ids_from_query`),
|
||||||
# find the most recent state events that allowed that message to be
|
# find the most recent state events that allowed that message to be
|
||||||
# sent. We will use that as a base to auth our historical messages
|
# sent. We will use that as a base to auth our historical messages
|
||||||
|
@ -131,14 +144,6 @@ class RoomBatchSendEventRestServlet(RestServlet):
|
||||||
prev_event_ids_from_query
|
prev_event_ids_from_query
|
||||||
)
|
)
|
||||||
|
|
||||||
if not state_event_ids:
|
|
||||||
raise SynapseError(
|
|
||||||
HTTPStatus.BAD_REQUEST,
|
|
||||||
"No auth events found for given prev_event query parameter. The prev_event=%s probably does not exist."
|
|
||||||
% prev_event_ids_from_query,
|
|
||||||
errcode=Codes.INVALID_PARAM,
|
|
||||||
)
|
|
||||||
|
|
||||||
state_event_ids_at_start = []
|
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
|
||||||
|
|
Loading…
Reference in a new issue