summary refs log tree commit diff
diff options
context:
space:
mode:
authorDaniel Wagner-Hall <daniel@matrix.org>2015-12-02 17:27:49 +0000
committerDaniel Wagner-Hall <daniel@matrix.org>2015-12-02 17:29:47 +0000
commit526bc33e023e9a588c1b96e500c15baf90c022fb (patch)
treeda260cc9155bd8fd5a5481cfb601aa23f788861f
parentMerge pull request #412 from matrix-org/erikj/search (diff)
downloadsynapse-526bc33e023e9a588c1b96e500c15baf90c022fb.tar.xz
Fix implementation of /admin/whois
Diffstat (limited to '')
-rw-r--r--synapse/handlers/admin.py28
-rw-r--r--synapse/rest/client/v1/admin.py2
2 files changed, 12 insertions, 18 deletions
diff --git a/synapse/handlers/admin.py b/synapse/handlers/admin.py
index d852a18555..5ba3c7039a 100644
--- a/synapse/handlers/admin.py
+++ b/synapse/handlers/admin.py
@@ -30,33 +30,27 @@ class AdminHandler(BaseHandler):
 
     @defer.inlineCallbacks
     def get_whois(self, user):
-        res = yield self.store.get_user_ip_and_agents(user)
-
-        d = {}
-        for r in res:
-            # Note that device_id is always None
-            device = d.setdefault(r["device_id"], {})
-            session = device.setdefault(r["access_token"], [])
-            session.append({
-                "ip": r["ip"],
-                "user_agent": r["user_agent"],
-                "last_seen": r["last_seen"],
+        connections = []
+
+        sessions = yield self.store.get_user_ip_and_agents(user)
+        for session in sessions:
+            connections.append({
+                "ip": session["ip"],
+                "last_seen": session["last_seen"],
+                "user_agent": session["user_agent"],
             })
 
         ret = {
             "user_id": user.to_string(),
             "devices": [
                 {
-                    "device_id": k,
+                    "device_id": None,
                     "sessions": [
                         {
-                            # "access_token": x, TODO (erikj)
-                            "connections": y,
+                            "connections": connections,
                         }
-                        for x, y in v.items()
                     ]
-                }
-                for k, v in d.items()
+                },
             ],
         }
 
diff --git a/synapse/rest/client/v1/admin.py b/synapse/rest/client/v1/admin.py
index 0103697889..886199a6da 100644
--- a/synapse/rest/client/v1/admin.py
+++ b/synapse/rest/client/v1/admin.py
@@ -26,7 +26,7 @@ logger = logging.getLogger(__name__)
 
 
 class WhoisRestServlet(ClientV1RestServlet):
-    PATTERNS = client_path_patterns("/admin/whois/(?P<user_id>[^/]*)", releases=())
+    PATTERNS = client_path_patterns("/admin/whois/(?P<user_id>[^/]*)")
 
     @defer.inlineCallbacks
     def on_GET(self, request, user_id):