From 9d60613dd73cf8f7d1935e1a92e6003637f66547 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Wed, 7 Jul 2021 16:22:30 -0500 Subject: [PATCH] Add more better comments --- synapse/rest/client/v1/room.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/synapse/rest/client/v1/room.py b/synapse/rest/client/v1/room.py index 25af9cd4292d..fabc40fbd420 100644 --- a/synapse/rest/client/v1/room.py +++ b/synapse/rest/client/v1/room.py @@ -350,17 +350,18 @@ async def inherit_depth_from_prev_ids(self, prev_event_ids) -> int: return depth def _create_insertion_event_dict(self, sender: str, origin_server_ts: int): - """ - Creates an event dict for an "insertion" event with the proper fields + """Creates an event dict for an "insertion" event with the proper fields and a random chunk ID. + Args: sender: The event author MXID origin_server_ts: Timestamp when the event was sent + Returns: Tuple of event ID and stream ordering position """ - next_chunk_id = random_string(64) + next_chunk_id = random_string(8) insertion_event = { "type": EventTypes.MSC2716_INSERTION, "sender": sender, @@ -481,8 +482,13 @@ async def on_POST(self, request, room_id): if chunk_id_from_query: # TODO: Verify the chunk_id_from_query corresponds to an insertion event pass - # Otherwise, create an insertion event to be based off of and connect - # to as a starting point. + # Otherwise, create an insertion event to act as a starting point. + # + # We don't always have an insertion event to start hanging more history + # off of (ideally there would be one in the main DAG, but that's not the + # case if we're wanting to add history to e.g. existing rooms without + # an insertion event), in which case we just create a new insertion event + # that can then get pointed to by a "marker" event later. else: base_insertion_event = self._create_insertion_event_dict( sender=requester.user.to_string(),