diff --git a/synapse/events/third_party_rules.py b/synapse/events/third_party_rules.py index af5032637a..253b025c27 100644 --- a/synapse/events/third_party_rules.py +++ b/synapse/events/third_party_rules.py @@ -28,9 +28,14 @@ class PublicRoomsManager: room_id: The ID of the room. Returns: - Whether the room is in the public rooms directory. + Whether the room is in the public rooms directory. Additionally returns False + if the room does not exist. """ - return await self._store.get_room_is_public(room_id) + room = await self._store.get_room(room_id) + if not room: + return False + + return room.get("is_public", False) async def add_room_to_public_directory(self, room_id: str) -> None: """Publishes a room to the public rooms directory. diff --git a/synapse/storage/databases/main/room.py b/synapse/storage/databases/main/room.py index 30450819fd..717df97301 100644 --- a/synapse/storage/databases/main/room.py +++ b/synapse/storage/databases/main/room.py @@ -133,25 +133,6 @@ class RoomWorkerStore(SQLBaseStore): desc="get_public_room_ids", ) - async def get_room_is_public(self, room_id: str) -> bool: - """Returns whether a given room is public. - - Args: - room_id: The ID of the room. - - Returns: - Whether the room is public. - """ - row = await self.db_pool.simple_select_onecol( - table="rooms", - keyvalues={"room_id": room_id}, - retcol="is_public", - desc="get_room_is_public", - ) - if row: - return bool(row[0]) - return False - async def count_public_rooms( self, network_tuple: Optional[ThirdPartyInstanceID],