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

Commit

Permalink
Handle review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep committed Nov 9, 2023
1 parent 3dc789d commit 9fe2ec5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions synapse/storage/databases/main/event_federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ async def get_auth_chain_ids(
# algorithm.
room = await self.get_room(room_id) # type: ignore[attr-defined]
# If the room has an auth chain index.
if room[2]:
if room[1]:
try:
return await self.db_pool.runInteraction(
"get_auth_chain_ids_chains",
Expand Down Expand Up @@ -413,7 +413,7 @@ async def get_auth_chain_difference(
# algorithm.
room = await self.get_room(room_id) # type: ignore[attr-defined]
# If the room has an auth chain index.
if room[2]:
if room[1]:
try:
return await self.db_pool.runInteraction(
"get_auth_chain_difference_chains",
Expand Down
12 changes: 7 additions & 5 deletions synapse/storage/databases/main/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,29 +213,31 @@ async def store_room(
logger.error("store_room with room_id=%s failed: %s", room_id, e)
raise StoreError(500, "Problem creating room.")

async def get_room(self, room_id: str) -> Optional[Tuple[bool, str, bool]]:
async def get_room(self, room_id: str) -> Optional[Tuple[bool, bool]]:
"""Retrieve a room.
Args:
room_id: The ID of the room to retrieve.
Returns:
A tuple containing the room information:
* True if the room is public
* The room creator
* True if the room has an auth chain index
or None if the room is unknown.
"""
return cast(
Optional[Tuple[bool, str, bool]],
row = cast(
Optional[Tuple[Optional[Union[int, bool]], Optional[Union[int, bool]]]],
await self.db_pool.simple_select_one(
table="rooms",
keyvalues={"room_id": room_id},
retcols=("is_public", "creator", "has_auth_chain_index"),
retcols=("is_public", "has_auth_chain_index"),
desc="get_room",
allow_none=True,
),
)
if row is None:
return row
return bool(row[0]), bool(row[1])

async def get_room_with_stats(self, room_id: str) -> Optional[RoomStats]:
"""Retrieve room with statistics.
Expand Down
1 change: 0 additions & 1 deletion tests/storage/test_room.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None:
def test_get_room(self) -> None:
room = self.get_success(self.store.get_room(self.room.to_string()))
assert room is not None
self.assertEqual(room[1], self.u_creator.to_string())
self.assertTrue(room[0])

def test_get_room_unknown_room(self) -> None:
Expand Down

0 comments on commit 9fe2ec5

Please sign in to comment.