aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/src/meshbay_node/ui/app.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-node/src/meshbay_node/ui/app.py')
-rw-r--r--packages/meshbay-node/src/meshbay_node/ui/app.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/packages/meshbay-node/src/meshbay_node/ui/app.py b/packages/meshbay-node/src/meshbay_node/ui/app.py
index 2f73868..28654df 100644
--- a/packages/meshbay-node/src/meshbay_node/ui/app.py
+++ b/packages/meshbay-node/src/meshbay_node/ui/app.py
@@ -243,6 +243,7 @@ def create_ui_app(state: dict) -> FastAPI:
role=ROLE_OPERATOR,
created_by="local-cli",
ttl=ttl,
+ username=(config.hub.username if config else ""),
)
invites = await roster.list_invites()
expires = next((i["expires_at"] for i in invites
@@ -292,6 +293,7 @@ def create_ui_app(state: dict) -> FastAPI:
role=ROLE_MEMBER,
created_by="local-cli",
ttl=ttl,
+ username=username,
)
invites = await roster.list_invites()
expires = next((i["expires_at"] for i in invites
@@ -300,6 +302,30 @@ def create_ui_app(state: dict) -> FastAPI:
return {"code": code, "expires_at": expires,
"username": username, "user_id": account["user_id"]}
+ @app.get("/api/resolve")
+ async def resolve_user(username: str):
+ """
+ Map a username to an account id for the CLI.
+
+ The roster answers first — it is the node's own record. The hub is the
+ fallback for identities pinned before invitations carried a name, and for
+ people admitted through an open-join group. Only an account id comes back;
+ no key is ever taken from here.
+ """
+ roster = state.get("roster")
+ if roster:
+ for ident in await roster.list_identities():
+ if ident["username"] == username:
+ return {"user_id": ident["user_id"], "source": "roster"}
+ hub = state.get("hub")
+ if hub and hub._session:
+ try:
+ account = await hub.get_user_pubkeys(username)
+ return {"user_id": account["user_id"], "source": "hub"}
+ except Exception:
+ pass
+ return JSONResponse({"error": f"Unknown user {username!r}"}, 404)
+
@app.post("/api/members/{user_id}/revoke")
async def revoke_member(user_id: str, group_id: str):
"""