Skip to content

Commit 79767a1

Browse files
authoredJun 18, 2024··
Add support for via query parameter from MSC4156 (#17322)
This adds support for the `via` query parameter from matrix-org/matrix-spec-proposals#4156.
1 parent 1c7d85f commit 79767a1

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed
 

‎changelog.d/17322.feature

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add support for via query parameter from MSC415.

‎synapse/config/experimental.py

+3
Original file line numberDiff line numberDiff line change
@@ -439,3 +439,6 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None:
439439

440440
# MSC4151: Report room API (Client-Server API)
441441
self.msc4151_enabled: bool = experimental.get("msc4151_enabled", False)
442+
443+
# MSC4156: Migrate server_name to via
444+
self.msc4156_enabled: bool = experimental.get("msc4156_enabled", False)

‎synapse/rest/client/knock.py

+8
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def __init__(self, hs: "HomeServer"):
5353
super().__init__()
5454
self.room_member_handler = hs.get_room_member_handler()
5555
self.auth = hs.get_auth()
56+
self._support_via = hs.config.experimental.msc4156_enabled
5657

5758
async def on_POST(
5859
self,
@@ -74,6 +75,13 @@ async def on_POST(
7475
remote_room_hosts = parse_strings_from_args(
7576
args, "server_name", required=False
7677
)
78+
if self._support_via:
79+
remote_room_hosts = parse_strings_from_args(
80+
args,
81+
"org.matrix.msc4156.via",
82+
default=remote_room_hosts,
83+
required=False,
84+
)
7785
elif RoomAlias.is_valid(room_identifier):
7886
handler = self.room_member_handler
7987
room_alias = RoomAlias.from_string(room_identifier)

‎synapse/rest/client/room.py

+8
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ def __init__(self, hs: "HomeServer"):
417417
super().__init__(hs)
418418
super(ResolveRoomIdMixin, self).__init__(hs) # ensure the Mixin is set up
419419
self.auth = hs.get_auth()
420+
self._support_via = hs.config.experimental.msc4156_enabled
420421

421422
def register(self, http_server: HttpServer) -> None:
422423
# /join/$room_identifier[/$txn_id]
@@ -435,6 +436,13 @@ async def _do(
435436
# twisted.web.server.Request.args is incorrectly defined as Optional[Any]
436437
args: Dict[bytes, List[bytes]] = request.args # type: ignore
437438
remote_room_hosts = parse_strings_from_args(args, "server_name", required=False)
439+
if self._support_via:
440+
remote_room_hosts = parse_strings_from_args(
441+
args,
442+
"org.matrix.msc4156.via",
443+
default=remote_room_hosts,
444+
required=False,
445+
)
438446
room_id, remote_room_hosts = await self.resolve_room_id(
439447
room_identifier,
440448
remote_room_hosts,

0 commit comments

Comments
 (0)
Please sign in to comment.