Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Fix implementation of /admin/whois #418

Merged
merged 1 commit into from
Dec 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 11 additions & 17 deletions synapse/handlers/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,33 +30,27 @@ def __init__(self, hs):

@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()
},
],
}

Expand Down
2 changes: 1 addition & 1 deletion synapse/rest/client/v1/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@


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):
Expand Down