mirror of
https://mau.dev/maunium/synapse.git
synced 2024-11-16 15:01:23 +01:00
Fix implementation of /admin/whois
This commit is contained in:
parent
f721fdbf87
commit
526bc33e02
2 changed files with 11 additions and 17 deletions
|
@ -30,33 +30,27 @@ class AdminHandler(BaseHandler):
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def get_whois(self, user):
|
def get_whois(self, user):
|
||||||
res = yield self.store.get_user_ip_and_agents(user)
|
connections = []
|
||||||
|
|
||||||
d = {}
|
sessions = yield self.store.get_user_ip_and_agents(user)
|
||||||
for r in res:
|
for session in sessions:
|
||||||
# Note that device_id is always None
|
connections.append({
|
||||||
device = d.setdefault(r["device_id"], {})
|
"ip": session["ip"],
|
||||||
session = device.setdefault(r["access_token"], [])
|
"last_seen": session["last_seen"],
|
||||||
session.append({
|
"user_agent": session["user_agent"],
|
||||||
"ip": r["ip"],
|
|
||||||
"user_agent": r["user_agent"],
|
|
||||||
"last_seen": r["last_seen"],
|
|
||||||
})
|
})
|
||||||
|
|
||||||
ret = {
|
ret = {
|
||||||
"user_id": user.to_string(),
|
"user_id": user.to_string(),
|
||||||
"devices": [
|
"devices": [
|
||||||
{
|
{
|
||||||
"device_id": k,
|
"device_id": None,
|
||||||
"sessions": [
|
"sessions": [
|
||||||
{
|
{
|
||||||
# "access_token": x, TODO (erikj)
|
"connections": connections,
|
||||||
"connections": y,
|
|
||||||
}
|
}
|
||||||
for x, y in v.items()
|
|
||||||
]
|
]
|
||||||
}
|
},
|
||||||
for k, v in d.items()
|
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class WhoisRestServlet(ClientV1RestServlet):
|
class WhoisRestServlet(ClientV1RestServlet):
|
||||||
PATTERNS = client_path_patterns("/admin/whois/(?P<user_id>[^/]*)", releases=())
|
PATTERNS = client_path_patterns("/admin/whois/(?P<user_id>[^/]*)")
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def on_GET(self, request, user_id):
|
def on_GET(self, request, user_id):
|
||||||
|
|
Loading…
Reference in a new issue