diff options
author | Daniel Wagner-Hall <dawagner@gmail.com> | 2015-12-03 12:18:01 +0000 |
---|---|---|
committer | Daniel Wagner-Hall <dawagner@gmail.com> | 2015-12-03 12:18:01 +0000 |
commit | e880164c5921a7f1a0591baf3f3587e769e095df (patch) | |
tree | b253ffa1464387c1400541783a27a232c1a72f0b /synapse/handlers/admin.py | |
parent | Merge pull request #417 from matrix-org/fix_db_v15_postgres (diff) | |
parent | Fix implementation of /admin/whois (diff) | |
download | synapse-e880164c5921a7f1a0591baf3f3587e769e095df.tar.xz |
Merge pull request #418 from matrix-org/daniel/whois
Merge pull request #418 from matrix-org/daniel/whois
Diffstat (limited to 'synapse/handlers/admin.py')
-rw-r--r-- | synapse/handlers/admin.py | 28 |
1 files changed, 11 insertions, 17 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() + }, ], } |