diff options
author | Patrick Cloke <patrickc@matrix.org> | 2023-07-11 15:50:08 -0400 |
---|---|---|
committer | Patrick Cloke <patrickc@matrix.org> | 2023-07-17 11:05:44 -0400 |
commit | b90edc168e975c2deebf19243d045070626a529e (patch) | |
tree | 119303fe28b333e64461ce04676c4d5da1e627ab | |
parent | Implement new send endpoint. (diff) | |
download | synapse-b90edc168e975c2deebf19243d045070626a529e.tar.xz |
Implement new device endpoint.
-rw-r--r-- | synapse/federation/transport/server/federation.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/synapse/federation/transport/server/federation.py b/synapse/federation/transport/server/federation.py index e06af8513a..5b98e6656e 100644 --- a/synapse/federation/transport/server/federation.py +++ b/synapse/federation/transport/server/federation.py @@ -764,6 +764,33 @@ class FederationUserDevicesQueryServlet(BaseFederationServerServlet): return await self.handler.on_query_user_devices(origin, user_id) +class FederationUnstableUserDeviceQueryServlet(BaseFederationServerServlet): + PREFIX = "unstable/org.matrix.i-d.ralston-mimi-linearized-matrix.02" + PATH = "/user/(?P<user_id>[^/]*)/device/(?P<device_id>[^/]*)" + CATEGORY = "Federation requests" + + async def on_GET( + self, + origin: str, + content: Literal[None], + query: Dict[bytes, List[bytes]], + user_id: str, + device_id: str, + ) -> Tuple[int, JsonDict]: + # TODO This is not efficient, we should only query the individual device. + _, result = await self.handler.on_query_user_devices(origin, user_id) + + # TODO 404 if not a local user or unknown user. + devices = result["devices"] + if device_id not in devices: + return 404, {} + + return 200, { + "user_id": user_id, + **devices[device_id], + } + + class FederationClientKeysClaimServlet(BaseFederationServerServlet): PATH = "/user/keys/claim" CATEGORY = "Federation requests" @@ -1031,4 +1058,5 @@ FEDERATION_SERVLET_CLASSES: Tuple[Type[BaseFederationServlet], ...] = ( FederationUnstableSendJoinServlet, FederationUnstableSendLeaveServlet, FederationUnstableSendKnockServlet, + FederationUnstableUserDeviceQueryServlet, ) |