Skip to content

Commit ba65d8c

Browse files
Put MSC2666 endpoint behind an experimental flag (#19219)
1 parent ae98771 commit ba65d8c

File tree

6 files changed

+39
-2
lines changed

6 files changed

+39
-2
lines changed

changelog.d/19219.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Require an experimental feature flag to be enabled in order for the unstable [MSC2666](https://github.com/matrix-org/matrix-spec-proposals/pull/2666) endpoint (`/_matrix/client/unstable/uk.half-shot.msc2666/user/mutual_rooms`) to be available.

docs/upgrade.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,17 @@ each upgrade are complete before moving on to the next upgrade, to avoid
117117
stacking them up. You can monitor the currently running background updates with
118118
[the Admin API](usage/administration/admin_api/background_updates.html#status).
119119
120+
# Upgrading to v1.144.0
121+
122+
## Unstable mutual rooms endpoint is now behind an experimental feature flag
123+
124+
The unstable mutual rooms endpoint from
125+
[MSC2666](https://github.com/matrix-org/matrix-spec-proposals/pull/2666)
126+
(`/_matrix/client/unstable/uk.half-shot.msc2666/user/mutual_rooms`) is now
127+
disabled by default. If you rely on this unstable endpoint, you must now set
128+
`experimental_features.msc2666_enabled: true` in your configuration to keep
129+
using it.
130+
120131
# Upgrading to v1.143.0
121132
122133
## Dropping support for PostgreSQL 13

synapse/config/experimental.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,9 @@ def read_config(
438438
# previously calculated push actions.
439439
self.msc2654_enabled: bool = experimental.get("msc2654_enabled", False)
440440

441+
# MSC2666: Query mutual rooms between two users.
442+
self.msc2666_enabled: bool = experimental.get("msc2666_enabled", False)
443+
441444
# MSC2815 (allow room moderators to view redacted event content)
442445
self.msc2815_enabled: bool = experimental.get("msc2815_enabled", False)
443446

synapse/rest/client/mutual_rooms.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,5 @@ async def on_GET(self, request: SynapseRequest) -> tuple[int, JsonDict]:
9090

9191

9292
def register_servlets(hs: "HomeServer", http_server: HttpServer) -> None:
93-
UserMutualRoomsServlet(hs).register(http_server)
93+
if hs.config.experimental.msc2666_enabled:
94+
UserMutualRoomsServlet(hs).register(http_server)

synapse/rest/client/versions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ async def on_GET(self, request: SynapseRequest) -> tuple[int, JsonDict]:
124124
# Implements additional endpoints as described in MSC2432
125125
"org.matrix.msc2432": True,
126126
# Implements additional endpoints as described in MSC2666
127-
"uk.half-shot.msc2666.query_mutual_rooms": True,
127+
"uk.half-shot.msc2666.query_mutual_rooms": self.config.experimental.msc2666_enabled,
128128
# Whether new rooms will be set to encrypted or not (based on presets).
129129
"io.element.e2ee_forced.public": self.e2ee_forced_public,
130130
"io.element.e2ee_forced.private": self.e2ee_forced_private,

tests/rest/client/test_mutual_rooms.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ class UserMutualRoomsTest(unittest.HomeserverTestCase):
4343
mutual_rooms.register_servlets,
4444
]
4545

46+
def default_config(self) -> dict:
47+
config = super().default_config()
48+
experimental = config.setdefault("experimental_features", {})
49+
experimental.setdefault("msc2666_enabled", True)
50+
return config
51+
4652
def make_homeserver(self, reactor: MemoryReactor, clock: Clock) -> HomeServer:
4753
config = self.default_config()
4854
return self.setup_test_homeserver(config=config)
@@ -58,6 +64,21 @@ def _get_mutual_rooms(self, token: str, other_user: str) -> FakeChannel:
5864
access_token=token,
5965
)
6066

67+
@unittest.override_config({"experimental_features": {"msc2666_enabled": False}})
68+
def test_mutual_rooms_no_experimental_flag(self) -> None:
69+
"""
70+
The endpoint should 404 if the experimental flag is not enabled.
71+
"""
72+
# Register a user.
73+
u1 = self.register_user("user1", "pass")
74+
u1_token = self.login(u1, "pass")
75+
76+
# Check that we're unable to query the endpoint due to the endpoint
77+
# being unrecognised.
78+
channel = self._get_mutual_rooms(u1_token, "@not-used:test")
79+
self.assertEqual(404, channel.code, channel.result)
80+
self.assertEqual("M_UNRECOGNIZED", channel.json_body["errcode"], channel.result)
81+
6182
def test_shared_room_list_public(self) -> None:
6283
"""
6384
A room should show up in the shared list of rooms between two users

0 commit comments

Comments
 (0)