From 4686cd0b49dcbd59c2994fb15660ceec0b626ace Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Thu, 9 Nov 2023 09:01:29 -0500 Subject: [PATCH] Handle review comments. --- synapse/storage/databases/main/event_federation.py | 4 ++-- synapse/storage/databases/main/room.py | 12 +++++++----- tests/storage/test_room.py | 1 - 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/synapse/storage/databases/main/event_federation.py b/synapse/storage/databases/main/event_federation.py index ce28fbf3d476..7e992ca4a28c 100644 --- a/synapse/storage/databases/main/event_federation.py +++ b/synapse/storage/databases/main/event_federation.py @@ -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", @@ -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", diff --git a/synapse/storage/databases/main/room.py b/synapse/storage/databases/main/room.py index bdf97e187667..ef26d5d9d37e 100644 --- a/synapse/storage/databases/main/room.py +++ b/synapse/storage/databases/main/room.py @@ -213,7 +213,7 @@ 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: @@ -221,21 +221,23 @@ async def get_room(self, room_id: str) -> Optional[Tuple[bool, str, bool]]: 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. diff --git a/tests/storage/test_room.py b/tests/storage/test_room.py index f5677c064d52..d3ffe963d32a 100644 --- a/tests/storage/test_room.py +++ b/tests/storage/test_room.py @@ -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: