fix: restore polished account experience and align AI with Lark design
This commit is contained in:
+9
-5
@@ -45,7 +45,7 @@ from .schemas import (
|
||||
from .security import bootstrap, cipher, issue_session, require_auth, token_hash, valid_password
|
||||
|
||||
|
||||
def account_output(account):
|
||||
def account_output(account, client):
|
||||
keys = (
|
||||
"email",
|
||||
"wq_user_id",
|
||||
@@ -59,7 +59,11 @@ def account_output(account):
|
||||
"timezone",
|
||||
"page_size",
|
||||
)
|
||||
return {**{k: getattr(account, k) for k in keys}, "configured": bool(account.password_encrypted)}
|
||||
return {
|
||||
**{k: getattr(account, k) for k in keys},
|
||||
"configured": bool(account.password_encrypted),
|
||||
"session": client.session_info(),
|
||||
}
|
||||
|
||||
|
||||
def csv_cell(value):
|
||||
@@ -189,7 +193,7 @@ def create_app(settings=None, wq_client=None, ai_model_factory=None):
|
||||
@api.get("/account", response_model=AccountOutput, tags=["account"])
|
||||
async def get_account():
|
||||
async with sessions() as db:
|
||||
return account_output(await db.get(Account, 1))
|
||||
return account_output(await db.get(Account, 1), runner.client)
|
||||
|
||||
@api.put("/account/credentials", response_model=AccountOutput, tags=["account"])
|
||||
async def credentials(body: CredentialsInput):
|
||||
@@ -203,7 +207,7 @@ def create_app(settings=None, wq_client=None, ai_model_factory=None):
|
||||
account.email = body.email
|
||||
account.password_encrypted = cipher(settings).encrypt(body.password.encode()).decode()
|
||||
await db.commit()
|
||||
return account_output(account)
|
||||
return account_output(account, runner.client)
|
||||
|
||||
@api.patch("/account/preferences", response_model=AccountOutput, tags=["account"])
|
||||
async def preferences(body: PreferencesInput):
|
||||
@@ -212,7 +216,7 @@ def create_app(settings=None, wq_client=None, ai_model_factory=None):
|
||||
for key, value in body.model_dump().items():
|
||||
setattr(account, key, value)
|
||||
await db.commit()
|
||||
return account_output(account)
|
||||
return account_output(account, runner.client)
|
||||
|
||||
async def account_job(kind):
|
||||
async with sessions() as db:
|
||||
|
||||
Reference in New Issue
Block a user