mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-08-15 07:35:40 -04:00
Hack together a query param for batch sending non-historical events
This commit is contained in:
parent
4d95e65860
commit
84d583f267
4 changed files with 70 additions and 18 deletions
|
@ -28,6 +28,7 @@ from synapse.http.servlet import (
|
|||
parse_json_object_from_request,
|
||||
parse_string,
|
||||
parse_strings_from_args,
|
||||
parse_boolean_from_args,
|
||||
)
|
||||
from synapse.http.site import SynapseRequest
|
||||
from synapse.rest.client.transactions import HttpTransactionCache
|
||||
|
@ -100,6 +101,7 @@ class RoomBatchSendEventRestServlet(RestServlet):
|
|||
request.args, "prev_event_id"
|
||||
)
|
||||
batch_id_from_query = parse_string(request, "batch_id")
|
||||
beeper_new_messages = parse_boolean_from_args(request.args, "com.beeper.new_messages")
|
||||
|
||||
if prev_event_ids_from_query is None:
|
||||
raise SynapseError(
|
||||
|
@ -148,7 +150,7 @@ class RoomBatchSendEventRestServlet(RestServlet):
|
|||
# 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
|
||||
# state events used to auth the upcoming historical messages.
|
||||
if body["state_events_at_start"]:
|
||||
if body["state_events_at_start"] and not beeper_new_messages:
|
||||
state_event_ids_at_start = (
|
||||
await self.room_batch_handler.persist_state_events_at_start(
|
||||
state_events_at_start=body["state_events_at_start"],
|
||||
|
@ -174,6 +176,8 @@ class RoomBatchSendEventRestServlet(RestServlet):
|
|||
base_insertion_event = None
|
||||
if batch_id_from_query:
|
||||
batch_id_to_connect_to = batch_id_from_query
|
||||
elif beeper_new_messages:
|
||||
batch_id_to_connect_to = None
|
||||
# Otherwise, create an insertion event to act as a starting point.
|
||||
#
|
||||
# We don't always have an insertion event to start hanging more history
|
||||
|
@ -224,11 +228,18 @@ class RoomBatchSendEventRestServlet(RestServlet):
|
|||
inherited_depth=inherited_depth,
|
||||
initial_state_event_ids=state_event_ids,
|
||||
app_service_requester=requester,
|
||||
beeper_new_messages=beeper_new_messages,
|
||||
beeper_initial_prev_event_ids=prev_event_ids_from_query if beeper_new_messages else None,
|
||||
)
|
||||
|
||||
insertion_event_id = event_ids[0]
|
||||
batch_event_id = event_ids[-1]
|
||||
historical_event_ids = event_ids[1:-1]
|
||||
if beeper_new_messages:
|
||||
insertion_event_id = batch_event_id = None
|
||||
historical_event_ids = event_ids
|
||||
next_batch_id = None
|
||||
else:
|
||||
insertion_event_id = event_ids[0]
|
||||
batch_event_id = event_ids[-1]
|
||||
historical_event_ids = event_ids[1:-1]
|
||||
|
||||
response_dict = {
|
||||
"state_event_ids": state_event_ids_at_start,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue