Skip to content
Snippets Groups Projects
Unverified Commit 3b4e1508 authored by Mathieu Velten's avatar Mathieu Velten Committed by GitHub
Browse files

Faster joins: use servers list approximation in `assert_host_in_room` (#14515)

parent f38d7d79
No related branches found
No related tags found
No related merge requests found
Faster joins: use servers list approximation received during `send_join` (potentially updated with received membership events) in `assert_host_in_room`.
\ No newline at end of file
...@@ -45,6 +45,7 @@ class EventAuthHandler: ...@@ -45,6 +45,7 @@ class EventAuthHandler:
def __init__(self, hs: "HomeServer"): def __init__(self, hs: "HomeServer"):
self._clock = hs.get_clock() self._clock = hs.get_clock()
self._store = hs.get_datastores().main self._store = hs.get_datastores().main
self._state_storage_controller = hs.get_storage_controllers().state
self._server_name = hs.hostname self._server_name = hs.hostname
async def check_auth_rules_from_context( async def check_auth_rules_from_context(
...@@ -179,17 +180,22 @@ class EventAuthHandler: ...@@ -179,17 +180,22 @@ class EventAuthHandler:
this function may return an incorrect result as we are not able to fully this function may return an incorrect result as we are not able to fully
track server membership in a room without full state. track server membership in a room without full state.
""" """
if not allow_partial_state_rooms and await self._store.is_partial_state_room( if await self._store.is_partial_state_room(room_id):
room_id if allow_partial_state_rooms:
): current_hosts = await self._state_storage_controller.get_current_hosts_in_room_or_partial_state_approximation(
raise AuthError( room_id
403, )
"Unable to authorise you right now; room is partial-stated here.", if host not in current_hosts:
errcode=Codes.UNABLE_DUE_TO_PARTIAL_STATE, raise AuthError(403, "Host not in room (partial-state approx).")
) else:
raise AuthError(
if not await self.is_host_in_room(room_id, host): 403,
raise AuthError(403, "Host not in room.") "Unable to authorise you right now; room is partial-stated here.",
errcode=Codes.UNABLE_DUE_TO_PARTIAL_STATE,
)
else:
if not await self.is_host_in_room(room_id, host):
raise AuthError(403, "Host not in room.")
async def check_restricted_join_rules( async def check_restricted_join_rules(
self, self,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment