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

Commit

Permalink
WIP Join during fast join
Browse files Browse the repository at this point in the history
Signed-off-by: Mathieu Velten <[email protected]>
  • Loading branch information
Mathieu Velten committed Dec 15, 2022
1 parent 54c012c commit 1e928ab
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.d/14606.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Faster joins: handle join during fast join.
6 changes: 4 additions & 2 deletions synapse/handlers/federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,8 @@ async def do_invite_join(
except ValueError:
pass

already_partially_joined = await self.store.is_partial_state_room(room_id)

ret = await self.federation_client.send_join(
host_list, event, room_version_obj
)
Expand Down Expand Up @@ -629,7 +631,7 @@ async def do_invite_join(
state_events=state,
)

if ret.partial_state:
if ret.partial_state and not already_partially_joined:
# Mark the room as having partial state.
# The background process is responsible for unmarking this flag,
# even if the join fails.
Expand Down Expand Up @@ -676,7 +678,7 @@ async def do_invite_join(
# state for the room.
# If the join failed, the background process is responsible for
# cleaning up — including unmarking the room as a partial state room.
if ret.partial_state:
if ret.partial_state and not already_partially_joined:
# Kick off the process of asynchronously fetching the state for this
# room.
run_as_background_process(
Expand Down
17 changes: 16 additions & 1 deletion synapse/handlers/room_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,10 +821,25 @@ async def update_membership_locked(
origin_server_ts=origin_server_ts,
)

is_partial_state_room = await self.store.is_partial_state_room(room_id)

await_full_state = True
# Join is ok because instead of relying on the events to validate it if the
# server is already partially joined, we will do make_join-send_join
#
# Leave doesn't really need validation: if the target has been banned in the
# meantime, we should have received the event and if not, state res at fed
# level will take care of solving the discrepancy.
if is_partial_state_room:
if get_domain_from_id(
target.to_string()
) == self._server_name and action in [Membership.JOIN, Membership.LEAVE]:
await_full_state = False

latest_event_ids = await self.store.get_prev_events_for_room(room_id)

state_before_join = await self.state_handler.compute_state_after_events(
room_id, latest_event_ids
room_id, latest_event_ids, await_full_state=await_full_state
)

# TODO: Refactor into dictionary of explicitly allowed transitions
Expand Down

0 comments on commit 1e928ab

Please sign in to comment.