diff options
author | Erik Johnston <erikj@element.io> | 2024-07-05 13:04:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-05 13:04:27 +0100 |
commit | 8e9e6f1a0a98d132ba4e57c394eabc7750aead84 (patch) | |
tree | 71c727d7ced1b7588df6cee2015d4514c4b95f5b /synapse/rest | |
parent | Finish up work to allow per-user feature flags (#17392) (diff) | |
download | synapse-8e9e6f1a0a98d132ba4e57c394eabc7750aead84.tar.xz |
Allow enabling sliding sync per-user (#17393)
Based on #17392
Diffstat (limited to 'synapse/rest')
-rw-r--r-- | synapse/rest/admin/experimental_features.py | 3 | ||||
-rw-r--r-- | synapse/rest/client/sync.py | 15 |
2 files changed, 13 insertions, 5 deletions
diff --git a/synapse/rest/admin/experimental_features.py b/synapse/rest/admin/experimental_features.py index c1559c92f7..d7913896d9 100644 --- a/synapse/rest/admin/experimental_features.py +++ b/synapse/rest/admin/experimental_features.py @@ -42,10 +42,13 @@ class ExperimentalFeature(str, Enum): """ MSC3881 = "msc3881" + MSC3575 = "msc3575" def is_globally_enabled(self, config: "HomeServerConfig") -> bool: if self is ExperimentalFeature.MSC3881: return config.experimental.msc3881_enabled + if self is ExperimentalFeature.MSC3575: + return config.experimental.msc3575_enabled assert_never(self) diff --git a/synapse/rest/client/sync.py b/synapse/rest/client/sync.py index e52e771538..2a22bc14ec 100644 --- a/synapse/rest/client/sync.py +++ b/synapse/rest/client/sync.py @@ -53,6 +53,7 @@ from synapse.http.servlet import ( ) from synapse.http.site import SynapseRequest from synapse.logging.opentracing import trace_with_opname +from synapse.rest.admin.experimental_features import ExperimentalFeature from synapse.types import JsonDict, Requester, StreamToken from synapse.types.rest.client import SlidingSyncBody from synapse.util import json_decoder @@ -673,7 +674,9 @@ class SlidingSyncE2eeRestServlet(RestServlet): ) async def on_GET(self, request: SynapseRequest) -> Tuple[int, JsonDict]: - requester = await self.auth.get_user_by_req(request, allow_guest=True) + requester = await self.auth.get_user_by_req_experimental_feature( + request, allow_guest=True, feature=ExperimentalFeature.MSC3575 + ) user = requester.user device_id = requester.device_id @@ -873,7 +876,10 @@ class SlidingSyncRestServlet(RestServlet): self.event_serializer = hs.get_event_client_serializer() async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]: - requester = await self.auth.get_user_by_req(request, allow_guest=True) + requester = await self.auth.get_user_by_req_experimental_feature( + request, allow_guest=True, feature=ExperimentalFeature.MSC3575 + ) + user = requester.user device_id = requester.device_id @@ -1051,6 +1057,5 @@ class SlidingSyncRestServlet(RestServlet): def register_servlets(hs: "HomeServer", http_server: HttpServer) -> None: SyncRestServlet(hs).register(http_server) - if hs.config.experimental.msc3575_enabled: - SlidingSyncRestServlet(hs).register(http_server) - SlidingSyncE2eeRestServlet(hs).register(http_server) + SlidingSyncRestServlet(hs).register(http_server) + SlidingSyncE2eeRestServlet(hs).register(http_server) |