Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Mark all MSC2716 events as historical (#10537)
Browse files Browse the repository at this point in the history
* Mark all MSC2716 events as historical
  • Loading branch information
MadLittleMods authored Aug 6, 2021
1 parent 0cb4274 commit f5a368b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions changelog.d/10537.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Mark all events stemming from the MSC2716 `/batch_send` endpoint as historical.
15 changes: 10 additions & 5 deletions synapse/rest/client/v1/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,9 @@ async def on_POST(self, request, room_id):
"state_key": state_event["state_key"],
}

# Mark all events as historical
event_dict["content"][EventContentFields.MSC2716_HISTORICAL] = True

# Make the state events float off on their own
fake_prev_event_id = "$" + random_string(43)

Expand Down Expand Up @@ -562,7 +565,10 @@ async def on_POST(self, request, room_id):
"type": EventTypes.MSC2716_CHUNK,
"sender": requester.user.to_string(),
"room_id": room_id,
"content": {EventContentFields.MSC2716_CHUNK_ID: chunk_id_to_connect_to},
"content": {
EventContentFields.MSC2716_CHUNK_ID: chunk_id_to_connect_to,
EventContentFields.MSC2716_HISTORICAL: True,
},
# Since the chunk event is put at the end of the chunk,
# where the newest-in-time event is, copy the origin_server_ts from
# the last event we're inserting
Expand All @@ -589,10 +595,6 @@ async def on_POST(self, request, room_id):
for ev in events_to_create:
assert_params_in_dict(ev, ["type", "origin_server_ts", "content", "sender"])

# Mark all events as historical
# This has important semantics within the Synapse internals to backfill properly
ev["content"][EventContentFields.MSC2716_HISTORICAL] = True

event_dict = {
"type": ev["type"],
"origin_server_ts": ev["origin_server_ts"],
Expand All @@ -602,6 +604,9 @@ async def on_POST(self, request, room_id):
"prev_events": prev_event_ids.copy(),
}

# Mark all events as historical
event_dict["content"][EventContentFields.MSC2716_HISTORICAL] = True

event, context = await self.event_creation_handler.create_event(
await self._create_requester_for_user_id_from_app_service(
ev["sender"], requester.app_service
Expand Down

0 comments on commit f5a368b

Please sign in to comment.