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

Commit

Permalink
Merge pull request #418 from matrix-org/daniel/whois
Browse files Browse the repository at this point in the history
Merge pull request #418 from matrix-org/daniel/whois
  • Loading branch information
illicitonion committed Dec 3, 2015
2 parents 181616d + 526bc33 commit e880164
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
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

0 comments on commit e880164

Please sign in to comment.