summary refs log tree commit diff
path: root/synapse/rest
diff options
context:
space:
mode:
authorTravis Ralston <travisr@matrix.org>2021-07-26 23:28:20 -0600
committerGitHub <noreply@github.com>2021-07-27 05:28:20 +0000
commitb3a757eb3b11151b1fac7833d6be239c9084f725 (patch)
tree9c3be54f7d350e1c1acf0c42817dec88a52f6b03 /synapse/rest
parentAdd type hints to state handler. (#10482) (diff)
downloadsynapse-b3a757eb3b11151b1fac7833d6be239c9084f725.tar.xz
Support MSC2033: Device ID on whoami (#9918)
* Fix no-access-token bug in deactivation tests
* Support MSC2033: Device ID on whoami
* Test for appservices too

MSC: https://github.com/matrix-org/matrix-doc/pull/2033

The MSC has passed FCP, which means stable endpoints can be used.
Diffstat (limited to 'synapse/rest')
-rw-r--r--synapse/rest/client/v2_alpha/account.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/synapse/rest/client/v2_alpha/account.py b/synapse/rest/client/v2_alpha/account.py
index 085561d3e9..fb5ad2906e 100644
--- a/synapse/rest/client/v2_alpha/account.py
+++ b/synapse/rest/client/v2_alpha/account.py
@@ -884,7 +884,14 @@ class WhoamiRestServlet(RestServlet):
     async def on_GET(self, request):
         requester = await self.auth.get_user_by_req(request)
 
-        return 200, {"user_id": requester.user.to_string()}
+        response = {"user_id": requester.user.to_string()}
+
+        # Appservices and similar accounts do not have device IDs
+        # that we can report on, so exclude them for compliance.
+        if requester.device_id is not None:
+            response["device_id"] = requester.device_id
+
+        return 200, response
 
 
 def register_servlets(hs, http_server):