mirror of
https://github.com/element-hq/synapse.git
synced 2024-11-21 09:05:42 +03:00
Allow GET /devices/:device_id to run on worker
This commit is contained in:
parent
b1e2946280
commit
eb0787d0cb
3 changed files with 19 additions and 7 deletions
|
@ -172,7 +172,6 @@ class ClientRestResource(JsonResource):
|
|||
|
||||
for servletfunc in SERVLET_GROUPS[servlet_group]:
|
||||
if not is_main_process and servletfunc in [
|
||||
pusher.register_servlets,
|
||||
logout.register_servlets,
|
||||
auth.register_servlets,
|
||||
tokenrefresh.register_servlets,
|
||||
|
|
|
@ -144,13 +144,13 @@ class DeviceRestServlet(RestServlet):
|
|||
super().__init__()
|
||||
self.hs = hs
|
||||
self.auth = hs.get_auth()
|
||||
handler = hs.get_device_handler()
|
||||
assert isinstance(handler, DeviceHandler)
|
||||
self.device_handler = handler
|
||||
self.device_handler = hs.get_device_handler()
|
||||
self.auth_handler = hs.get_auth_handler()
|
||||
self._msc3852_enabled = hs.config.experimental.msc3852_enabled
|
||||
self._msc3861_oauth_delegation_enabled = hs.config.experimental.msc3861.enabled
|
||||
|
||||
self._is_main_process = hs.config.worker.worker_app is None
|
||||
|
||||
async def on_GET(
|
||||
self, request: SynapseRequest, device_id: str
|
||||
) -> Tuple[int, JsonDict]:
|
||||
|
@ -181,6 +181,11 @@ class DeviceRestServlet(RestServlet):
|
|||
async def on_DELETE(
|
||||
self, request: SynapseRequest, device_id: str
|
||||
) -> Tuple[int, JsonDict]:
|
||||
if not self._is_main_process:
|
||||
raise UnrecognizedRequestError(code=404)
|
||||
|
||||
assert isinstance(self.device_handler, DeviceHandler)
|
||||
|
||||
if self._msc3861_oauth_delegation_enabled:
|
||||
raise UnrecognizedRequestError(code=404)
|
||||
|
||||
|
@ -219,6 +224,11 @@ class DeviceRestServlet(RestServlet):
|
|||
async def on_PUT(
|
||||
self, request: SynapseRequest, device_id: str
|
||||
) -> Tuple[int, JsonDict]:
|
||||
if not self._is_main_process:
|
||||
raise UnrecognizedRequestError(code=404)
|
||||
|
||||
assert isinstance(self.device_handler, DeviceHandler)
|
||||
|
||||
requester = await self.auth.get_user_by_req(request, allow_guest=True)
|
||||
|
||||
body = parse_and_validate_json_object_from_request(request, self.PutBody)
|
||||
|
@ -570,10 +580,11 @@ def register_servlets(hs: "HomeServer", http_server: HttpServer) -> None:
|
|||
and not hs.config.experimental.msc3861.enabled
|
||||
):
|
||||
DeleteDevicesRestServlet(hs).register(http_server)
|
||||
|
||||
DevicesRestServlet(hs).register(http_server)
|
||||
DeviceRestServlet(hs).register(http_server)
|
||||
|
||||
if hs.config.worker.worker_app is None:
|
||||
DeviceRestServlet(hs).register(http_server)
|
||||
if hs.config.experimental.msc2697_enabled:
|
||||
DehydratedDeviceServlet(hs).register(http_server)
|
||||
ClaimDehydratedDeviceServlet(hs).register(http_server)
|
||||
|
|
|
@ -177,5 +177,7 @@ class LegacyPushersRemoveRestServlet(UnsubscribeResource, RestServlet):
|
|||
|
||||
def register_servlets(hs: "HomeServer", http_server: HttpServer) -> None:
|
||||
PushersRestServlet(hs).register(http_server)
|
||||
PushersSetRestServlet(hs).register(http_server)
|
||||
LegacyPushersRemoveRestServlet(hs).register(http_server)
|
||||
|
||||
if hs.config.worker.worker_app is None:
|
||||
PushersSetRestServlet(hs).register(http_server)
|
||||
LegacyPushersRemoveRestServlet(hs).register(http_server)
|
||||
|
|
Loading…
Reference in a new issue