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

Commit 3070af4

Browse files
authored
remote join processing: get create event from state, not auth_chain (#12039)
A follow-up to #12005, in which I apparently missed that there are a bunch of other places that assume the create event is in the auth chain.
1 parent a85dde3 commit 3070af4

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

changelog.d/12039.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Preparation for faster-room-join work: when parsing the `send_join` response, get the `m.room.create` event from `state`, not `auth_chain`.

synapse/federation/federation_client.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -870,13 +870,15 @@ async def _execute(pdu: EventBase) -> None:
870870
for s in signed_state:
871871
s.internal_metadata = copy.deepcopy(s.internal_metadata)
872872

873-
# double-check that the same create event has ended up in the auth chain
873+
# double-check that the auth chain doesn't include a different create event
874874
auth_chain_create_events = [
875875
e.event_id
876876
for e in signed_auth
877877
if (e.type, e.state_key) == (EventTypes.Create, "")
878878
]
879-
if auth_chain_create_events != [create_event.event_id]:
879+
if auth_chain_create_events and auth_chain_create_events != [
880+
create_event.event_id
881+
]:
880882
raise InvalidResponseError(
881883
"Unexpected create event(s) in auth chain: %s"
882884
% (auth_chain_create_events,)

synapse/handlers/federation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ async def do_invite_join(
516516
await self.store.upsert_room_on_join(
517517
room_id=room_id,
518518
room_version=room_version_obj,
519-
auth_events=auth_chain,
519+
state_events=state,
520520
)
521521

522522
max_stream_id = await self._federation_event_handler.process_remote_join(

synapse/storage/databases/main/room.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,7 +1498,7 @@ def __init__(
14981498
self._event_reports_id_gen = IdGenerator(db_conn, "event_reports", "id")
14991499

15001500
async def upsert_room_on_join(
1501-
self, room_id: str, room_version: RoomVersion, auth_events: List[EventBase]
1501+
self, room_id: str, room_version: RoomVersion, state_events: List[EventBase]
15021502
) -> None:
15031503
"""Ensure that the room is stored in the table
15041504
@@ -1511,7 +1511,7 @@ async def upsert_room_on_join(
15111511
has_auth_chain_index = await self.has_auth_chain_index(room_id)
15121512

15131513
create_event = None
1514-
for e in auth_events:
1514+
for e in state_events:
15151515
if (e.type, e.state_key) == (EventTypes.Create, ""):
15161516
create_event = e
15171517
break

0 commit comments

Comments
 (0)