Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/12039.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Preparation for faster-room-join work: when parsing the `send_join` response, get the `m.room.create` event from `state`, not `auth_chain`.
6 changes: 4 additions & 2 deletions synapse/federation/federation_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -870,13 +870,15 @@ async def _execute(pdu: EventBase) -> None:
for s in signed_state:
s.internal_metadata = copy.deepcopy(s.internal_metadata)

# double-check that the same create event has ended up in the auth chain
# double-check that the auth chain doesn't include a different create event
auth_chain_create_events = [
e.event_id
for e in signed_auth
if (e.type, e.state_key) == (EventTypes.Create, "")
]
if auth_chain_create_events != [create_event.event_id]:
if auth_chain_create_events and auth_chain_create_events != [
create_event.event_id
]:
raise InvalidResponseError(
"Unexpected create event(s) in auth chain: %s"
% (auth_chain_create_events,)
Expand Down
4 changes: 3 additions & 1 deletion synapse/handlers/federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

"""Contains handlers for federation events."""

import itertools
import logging
from http import HTTPStatus
from typing import TYPE_CHECKING, Dict, Iterable, List, Optional, Tuple, Union
Expand Down Expand Up @@ -51,6 +52,7 @@
preserve_fn,
run_in_background,
)
from synapse.metrics.background_process_metrics import run_as_background_process
from synapse.replication.http.federation import (
ReplicationCleanRoomRestServlet,
ReplicationStoreRoomOnOutlierMembershipRestServlet,
Expand Down Expand Up @@ -516,7 +518,7 @@ async def do_invite_join(
await self.store.upsert_room_on_join(
room_id=room_id,
room_version=room_version_obj,
auth_events=auth_chain,
state_events=state,
)

max_stream_id = await self._federation_event_handler.process_remote_join(
Expand Down
4 changes: 2 additions & 2 deletions synapse/storage/databases/main/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,7 @@ def __init__(
self._event_reports_id_gen = IdGenerator(db_conn, "event_reports", "id")

async def upsert_room_on_join(
self, room_id: str, room_version: RoomVersion, auth_events: List[EventBase]
self, room_id: str, room_version: RoomVersion, state_events: List[EventBase]
) -> None:
"""Ensure that the room is stored in the table

Expand All @@ -1511,7 +1511,7 @@ async def upsert_room_on_join(
has_auth_chain_index = await self.has_auth_chain_index(room_id)

create_event = None
for e in auth_events:
for e in state_events:
if (e.type, e.state_key) == (EventTypes.Create, ""):
create_event = e
break
Expand Down