|
| 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