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

Commit

Permalink
Rename check_ to is_ to more accurately describe it
Browse files Browse the repository at this point in the history
  • Loading branch information
reivilibre committed Sep 22, 2022
1 parent 51f7609 commit bd3e33c
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 12 deletions.
4 changes: 2 additions & 2 deletions synapse/handlers/event_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ async def get_user_which_could_invite(
Codes.UNABLE_TO_GRANT_JOIN,
)

async def check_host_in_room(self, room_id: str, host: str) -> bool:
async def is_host_in_room(self, room_id: str, host: str) -> bool:
with Measure(self._clock, "check_host_in_room"):
return await self._store.is_host_joined(room_id, host)

Expand All @@ -178,7 +178,7 @@ async def assert_host_in_room(
errcode=Codes.UNABLE_DUE_TO_PARTIAL_STATE,
)

if await self.check_host_in_room(room_id, host):
if await self.is_host_in_room(room_id, host):
raise AuthError(403, "Host not in room.")

async def check_restricted_join_rules(
Expand Down
4 changes: 2 additions & 2 deletions synapse/handlers/federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ async def on_make_join_request(
)

# now check that we are *still* in the room
is_in_room = await self._event_auth_handler.check_host_in_room(
is_in_room = await self._event_auth_handler.is_host_in_room(
room_id, self.server_name
)
if not is_in_room:
Expand Down Expand Up @@ -1249,7 +1249,7 @@ async def exchange_third_party_invite(
"state_key": target_user_id,
}

if await self._event_auth_handler.check_host_in_room(room_id, self.hs.hostname):
if await self._event_auth_handler.is_host_in_room(room_id, self.hs.hostname):
room_version_obj = await self.store.get_room_version(room_id)
builder = self.event_builder_factory.for_room_version(
room_version_obj, event_dict
Expand Down
2 changes: 1 addition & 1 deletion synapse/handlers/federation_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ async def on_receive_pdu(self, origin: str, pdu: EventBase) -> None:
#
# Note that if we were never in the room then we would have already
# dropped the event, since we wouldn't know the room version.
is_in_room = await self._event_auth_handler.check_host_in_room(
is_in_room = await self._event_auth_handler.is_host_in_room(
room_id, self._server_name
)
if not is_in_room:
Expand Down
2 changes: 1 addition & 1 deletion synapse/handlers/receipts.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ async def _received_remote_receipt(self, origin: str, content: JsonDict) -> None
# If we're not in the room just ditch the event entirely. This is
# probably an old server that has come back and thinks we're still in
# the room (or we've been rejoined to the room by a state reset).
is_in_room = await self.event_auth_handler.check_host_in_room(
is_in_room = await self.event_auth_handler.is_host_in_room(
room_id, self.server_name
)
if not is_in_room:
Expand Down
6 changes: 2 additions & 4 deletions synapse/handlers/room_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ async def _is_local_room_accessible(
# If this is a request over federation, check if the host is in the room or
# has a user who could join the room.
elif origin:
if await self._event_auth_handler.check_host_in_room(
if await self._event_auth_handler.is_host_in_room(
room_id, origin
) or await self._store.is_host_invited(room_id, origin):
return True
Expand All @@ -624,9 +624,7 @@ async def _is_local_room_accessible(
await self._event_auth_handler.get_rooms_that_allow_join(state_ids)
)
for space_id in allowed_rooms:
if await self._event_auth_handler.check_host_in_room(
space_id, origin
):
if await self._event_auth_handler.is_host_in_room(space_id, origin):
return True

logger.info(
Expand Down
2 changes: 1 addition & 1 deletion synapse/handlers/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ async def _recv_edu(self, origin: str, content: JsonDict) -> None:
# If we're not in the room just ditch the event entirely. This is
# probably an old server that has come back and thinks we're still in
# the room (or we've been rejoined to the room by a state reset).
is_in_room = await self.event_auth_handler.check_host_in_room(
is_in_room = await self.event_auth_handler.is_host_in_room(
room_id, self.server_name
)
if not is_in_room:
Expand Down
2 changes: 1 addition & 1 deletion tests/handlers/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ async def check_user_in_room(room_id: str, requester: Requester) -> None:
async def check_host_in_room(room_id: str, server_name: str) -> bool:
return room_id == ROOM_ID

hs.get_event_auth_handler().check_host_in_room = check_host_in_room
hs.get_event_auth_handler().is_host_in_room = check_host_in_room

async def get_current_hosts_in_room(room_id: str):
return {member.domain for member in self.room_members}
Expand Down

0 comments on commit bd3e33c

Please sign in to comment.