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.
This commit is contained in:
parent
a85dde3445
commit
3070af4809
|
@ -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`.
|
|
@ -870,13 +870,15 @@ class FederationClient(FederationBase):
|
||||||
for s in signed_state:
|
for s in signed_state:
|
||||||
s.internal_metadata = copy.deepcopy(s.internal_metadata)
|
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 = [
|
auth_chain_create_events = [
|
||||||
e.event_id
|
e.event_id
|
||||||
for e in signed_auth
|
for e in signed_auth
|
||||||
if (e.type, e.state_key) == (EventTypes.Create, "")
|
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(
|
raise InvalidResponseError(
|
||||||
"Unexpected create event(s) in auth chain: %s"
|
"Unexpected create event(s) in auth chain: %s"
|
||||||
% (auth_chain_create_events,)
|
% (auth_chain_create_events,)
|
||||||
|
|
|
@ -516,7 +516,7 @@ class FederationHandler:
|
||||||
await self.store.upsert_room_on_join(
|
await self.store.upsert_room_on_join(
|
||||||
room_id=room_id,
|
room_id=room_id,
|
||||||
room_version=room_version_obj,
|
room_version=room_version_obj,
|
||||||
auth_events=auth_chain,
|
state_events=state,
|
||||||
)
|
)
|
||||||
|
|
||||||
max_stream_id = await self._federation_event_handler.process_remote_join(
|
max_stream_id = await self._federation_event_handler.process_remote_join(
|
||||||
|
|
|
@ -1498,7 +1498,7 @@ class RoomStore(RoomBackgroundUpdateStore, RoomWorkerStore):
|
||||||
self._event_reports_id_gen = IdGenerator(db_conn, "event_reports", "id")
|
self._event_reports_id_gen = IdGenerator(db_conn, "event_reports", "id")
|
||||||
|
|
||||||
async def upsert_room_on_join(
|
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:
|
) -> None:
|
||||||
"""Ensure that the room is stored in the table
|
"""Ensure that the room is stored in the table
|
||||||
|
|
||||||
|
@ -1511,7 +1511,7 @@ class RoomStore(RoomBackgroundUpdateStore, RoomWorkerStore):
|
||||||
has_auth_chain_index = await self.has_auth_chain_index(room_id)
|
has_auth_chain_index = await self.has_auth_chain_index(room_id)
|
||||||
|
|
||||||
create_event = None
|
create_event = None
|
||||||
for e in auth_events:
|
for e in state_events:
|
||||||
if (e.type, e.state_key) == (EventTypes.Create, ""):
|
if (e.type, e.state_key) == (EventTypes.Create, ""):
|
||||||
create_event = e
|
create_event = e
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in New Issue