summary refs log tree commit diff
diff options
context:
space:
mode:
authorJohannes Marbach <n0-0ne+github@mailbox.org>2024-06-18 12:03:39 +0200
committerGitHub <noreply@github.com>2024-06-18 10:03:39 +0000
commit79767a1108a9a126b18e063eb7e8b063cac94e66 (patch)
tree46ff81878c0aad82fff56de27d2be7bb47590a62
parentfix missing quotes for exclude_rooms_from_sync (#17308) (diff)
downloadsynapse-79767a1108a9a126b18e063eb7e8b063cac94e66.tar.xz
Add support for via query parameter from MSC4156 (#17322)
This adds support for the `via` query parameter from
https://github.com/matrix-org/matrix-spec-proposals/pull/4156.
-rw-r--r--changelog.d/17322.feature1
-rw-r--r--synapse/config/experimental.py3
-rw-r--r--synapse/rest/client/knock.py8
-rw-r--r--synapse/rest/client/room.py8
4 files changed, 20 insertions, 0 deletions
diff --git a/changelog.d/17322.feature b/changelog.d/17322.feature
new file mode 100644
index 0000000000..85386c2df7
--- /dev/null
+++ b/changelog.d/17322.feature
@@ -0,0 +1 @@
+Add support for via query parameter from MSC415.
diff --git a/synapse/config/experimental.py b/synapse/config/experimental.py
index 24546171e5..23e96da6a3 100644
--- a/synapse/config/experimental.py
+++ b/synapse/config/experimental.py
@@ -439,3 +439,6 @@ class ExperimentalConfig(Config):
 
         # MSC4151: Report room API (Client-Server API)
         self.msc4151_enabled: bool = experimental.get("msc4151_enabled", False)
+
+        # MSC4156: Migrate server_name to via
+        self.msc4156_enabled: bool = experimental.get("msc4156_enabled", False)
diff --git a/synapse/rest/client/knock.py b/synapse/rest/client/knock.py
index ff52a9bf8c..e31687fc13 100644
--- a/synapse/rest/client/knock.py
+++ b/synapse/rest/client/knock.py
@@ -53,6 +53,7 @@ class KnockRoomAliasServlet(RestServlet):
         super().__init__()
         self.room_member_handler = hs.get_room_member_handler()
         self.auth = hs.get_auth()
+        self._support_via = hs.config.experimental.msc4156_enabled
 
     async def on_POST(
         self,
@@ -74,6 +75,13 @@ class KnockRoomAliasServlet(RestServlet):
             remote_room_hosts = parse_strings_from_args(
                 args, "server_name", required=False
             )
+            if self._support_via:
+                remote_room_hosts = parse_strings_from_args(
+                    args,
+                    "org.matrix.msc4156.via",
+                    default=remote_room_hosts,
+                    required=False,
+                )
         elif RoomAlias.is_valid(room_identifier):
             handler = self.room_member_handler
             room_alias = RoomAlias.from_string(room_identifier)
diff --git a/synapse/rest/client/room.py b/synapse/rest/client/room.py
index 61fdf71a27..c98241f6ce 100644
--- a/synapse/rest/client/room.py
+++ b/synapse/rest/client/room.py
@@ -417,6 +417,7 @@ class JoinRoomAliasServlet(ResolveRoomIdMixin, TransactionRestServlet):
         super().__init__(hs)
         super(ResolveRoomIdMixin, self).__init__(hs)  # ensure the Mixin is set up
         self.auth = hs.get_auth()
+        self._support_via = hs.config.experimental.msc4156_enabled
 
     def register(self, http_server: HttpServer) -> None:
         # /join/$room_identifier[/$txn_id]
@@ -435,6 +436,13 @@ class JoinRoomAliasServlet(ResolveRoomIdMixin, TransactionRestServlet):
         # twisted.web.server.Request.args is incorrectly defined as Optional[Any]
         args: Dict[bytes, List[bytes]] = request.args  # type: ignore
         remote_room_hosts = parse_strings_from_args(args, "server_name", required=False)
+        if self._support_via:
+            remote_room_hosts = parse_strings_from_args(
+                args,
+                "org.matrix.msc4156.via",
+                default=remote_room_hosts,
+                required=False,
+            )
         room_id, remote_room_hosts = await self.resolve_room_id(
             room_identifier,
             remote_room_hosts,