Use stable prefixes for MSC3827: filtering of /publicRooms by room type (#13370)

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
Šimon Brandner 2022-07-27 20:46:57 +02:00 committed by GitHub
parent 922b771337
commit 583f22780f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 8 additions and 11 deletions

View File

@ -0,0 +1 @@
Use stable prefixes for [MSC3827](https://github.com/matrix-org/matrix-spec-proposals/pull/3827).

View File

@ -268,4 +268,4 @@ class PublicRoomsFilterFields:
""" """
GENERIC_SEARCH_TERM: Final = "generic_search_term" GENERIC_SEARCH_TERM: Final = "generic_search_term"
ROOM_TYPES: Final = "org.matrix.msc3827.room_types" ROOM_TYPES: Final = "room_types"

View File

@ -88,8 +88,5 @@ class ExperimentalConfig(Config):
# MSC3715: dir param on /relations. # MSC3715: dir param on /relations.
self.msc3715_enabled: bool = experimental.get("msc3715_enabled", False) self.msc3715_enabled: bool = experimental.get("msc3715_enabled", False)
# MSC3827: Filtering of /publicRooms by room type
self.msc3827_enabled: bool = experimental.get("msc3827_enabled", False)
# MSC3848: Introduce errcodes for specific event sending failures # MSC3848: Introduce errcodes for specific event sending failures
self.msc3848_enabled: bool = experimental.get("msc3848_enabled", False) self.msc3848_enabled: bool = experimental.get("msc3848_enabled", False)

View File

@ -182,7 +182,7 @@ class RoomListHandler:
== HistoryVisibility.WORLD_READABLE, == HistoryVisibility.WORLD_READABLE,
"guest_can_join": room["guest_access"] == "can_join", "guest_can_join": room["guest_access"] == "can_join",
"join_rule": room["join_rules"], "join_rule": room["join_rules"],
"org.matrix.msc3827.room_type": room["room_type"], "room_type": room["room_type"],
} }
# Filter out Nones rather omit the field altogether # Filter out Nones rather omit the field altogether

View File

@ -95,8 +95,8 @@ class VersionsRestServlet(RestServlet):
"org.matrix.msc3026.busy_presence": self.config.experimental.msc3026_enabled, "org.matrix.msc3026.busy_presence": self.config.experimental.msc3026_enabled,
# Supports receiving private read receipts as per MSC2285 # Supports receiving private read receipts as per MSC2285
"org.matrix.msc2285": self.config.experimental.msc2285_enabled, "org.matrix.msc2285": self.config.experimental.msc2285_enabled,
# Supports filtering of /publicRooms by room type MSC3827 # Supports filtering of /publicRooms by room type as per MSC3827
"org.matrix.msc3827": self.config.experimental.msc3827_enabled, "org.matrix.msc3827.stable": True,
# Adds support for importing historical messages as per MSC2716 # Adds support for importing historical messages as per MSC2716
"org.matrix.msc2716": self.config.experimental.msc2716_enabled, "org.matrix.msc2716": self.config.experimental.msc2716_enabled,
# Adds support for jump to date endpoints (/timestamp_to_event) as per MSC3030 # Adds support for jump to date endpoints (/timestamp_to_event) as per MSC3030

View File

@ -207,7 +207,7 @@ class RoomWorkerStore(CacheInvalidationWorkerStore):
def _construct_room_type_where_clause( def _construct_room_type_where_clause(
self, room_types: Union[List[Union[str, None]], None] self, room_types: Union[List[Union[str, None]], None]
) -> Tuple[Union[str, None], List[str]]: ) -> Tuple[Union[str, None], List[str]]:
if not room_types or not self.config.experimental.msc3827_enabled: if not room_types:
return None, [] return None, []
else: else:
# We use None when we want get rooms without a type # We use None when we want get rooms without a type

View File

@ -2070,7 +2070,6 @@ class PublicRoomsRoomTypeFilterTestCase(unittest.HomeserverTestCase):
config = self.default_config() config = self.default_config()
config["allow_public_rooms_without_auth"] = True config["allow_public_rooms_without_auth"] = True
config["experimental_features"] = {"msc3827_enabled": True}
self.hs = self.setup_test_homeserver(config=config) self.hs = self.setup_test_homeserver(config=config)
self.url = b"/_matrix/client/r0/publicRooms" self.url = b"/_matrix/client/r0/publicRooms"
@ -2123,13 +2122,13 @@ class PublicRoomsRoomTypeFilterTestCase(unittest.HomeserverTestCase):
chunk, count = self.make_public_rooms_request([None]) chunk, count = self.make_public_rooms_request([None])
self.assertEqual(count, 1) self.assertEqual(count, 1)
self.assertEqual(chunk[0].get("org.matrix.msc3827.room_type", None), None) self.assertEqual(chunk[0].get("room_type", None), None)
def test_returns_only_space_based_on_filter(self) -> None: def test_returns_only_space_based_on_filter(self) -> None:
chunk, count = self.make_public_rooms_request(["m.space"]) chunk, count = self.make_public_rooms_request(["m.space"])
self.assertEqual(count, 1) self.assertEqual(count, 1)
self.assertEqual(chunk[0].get("org.matrix.msc3827.room_type", None), "m.space") self.assertEqual(chunk[0].get("room_type", None), "m.space")
def test_returns_both_rooms_and_space_based_on_filter(self) -> None: def test_returns_both_rooms_and_space_based_on_filter(self) -> None:
chunk, count = self.make_public_rooms_request(["m.space", None]) chunk, count = self.make_public_rooms_request(["m.space", None])