Skip to content

Commit b26ee94

Browse files
committed
Add an unstable servlet, gated behind experimental config flag
1 parent d6c9007 commit b26ee94

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

synapse/config/experimental.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,9 @@ def read_config(
556556
# MSC4133: Custom profile fields
557557
self.msc4133_enabled: bool = experimental.get("msc4133_enabled", False)
558558

559+
# MSC4143: Matrix RTC Transport using Livekit Backend
560+
self.msc4143_enabled: bool = experimental.get("msc4143_enabled", False)
561+
559562
# MSC4169: Backwards-compatible redaction sending using `/send`
560563
self.msc4169_enabled: bool = experimental.get("msc4169_enabled", False)
561564

synapse/rest/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
login,
4343
login_token_request,
4444
logout,
45+
matrixrtc,
4546
mutual_rooms,
4647
notifications,
4748
openid,
@@ -89,6 +90,7 @@
8990
presence.register_servlets,
9091
directory.register_servlets,
9192
voip.register_servlets,
93+
matrixrtc.register_servlets,
9294
pusher.register_servlets,
9395
push_rule.register_servlets,
9496
logout.register_servlets,

synapse/rest/client/matrixrtc.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#
2+
# This file is licensed under the Affero General Public License (AGPL) version 3.
3+
#
4+
# Copyright (C) 2025 New Vector, Ltd
5+
#
6+
# This program is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU Affero General Public License as
8+
# published by the Free Software Foundation, either version 3 of the
9+
# License, or (at your option) any later version.
10+
#
11+
# See the GNU Affero General Public License for more details:
12+
# <https://www.gnu.org/licenses/agpl-3.0.html>.
13+
#
14+
# [This file includes modifications made by New Vector Limited]
15+
#
16+
#
17+
18+
from typing import TYPE_CHECKING, Tuple
19+
20+
from synapse.http.server import HttpServer
21+
from synapse.http.servlet import RestServlet
22+
from synapse.http.site import SynapseRequest
23+
from synapse.rest.client._base import client_patterns
24+
from synapse.types import JsonDict
25+
26+
if TYPE_CHECKING:
27+
from synapse.server import HomeServer
28+
29+
30+
class MatrixRTCRestServlet(RestServlet):
31+
PATTERNS = client_patterns(r"/org\.matrix\.msc4143/rtc/transports$", releases=())
32+
CATEGORY = "Client API requests"
33+
34+
def __init__(self, hs: "HomeServer"):
35+
super().__init__()
36+
self._hs = hs
37+
self._auth = hs.get_auth()
38+
self._transports = hs.config.matrix_rtc.transports
39+
40+
async def on_GET(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
41+
# Require authentication for this endpoint.
42+
await self._auth.get_user_by_req(request)
43+
44+
if self._transports:
45+
return 200, {"rtc_transports": self._transports}
46+
47+
return 200, {}
48+
49+
50+
def register_servlets(hs: "HomeServer", http_server: HttpServer) -> None:
51+
if hs.config.experimental.msc4143_enabled:
52+
MatrixRTCRestServlet(hs).register(http_server)

0 commit comments

Comments
 (0)