fix: restore polished account experience and align AI with Lark design
This commit is contained in:
@@ -159,12 +159,16 @@ class Runner:
|
||||
|
||||
async def refresh_profile(self):
|
||||
raw = await self.client.profile()
|
||||
# Confirm identity before fetching or storing additional account data.
|
||||
async with self.sessions() as db:
|
||||
account = await db.get(Account, 1)
|
||||
user_id = raw.get("id")
|
||||
if not user_id or (account.wq_user_id and account.wq_user_id != str(user_id)):
|
||||
self.client.disconnect()
|
||||
raise WqError("平台账户身份不匹配,请核对凭据", "identity_mismatch")
|
||||
usage = await self.client.account_usage()
|
||||
async with self.sessions() as db:
|
||||
account = await db.get(Account, 1)
|
||||
account.wq_user_id = str(user_id)
|
||||
# An allowlist avoids persisting unknown personal/security fields.
|
||||
account.profile = sanitize(
|
||||
@@ -177,6 +181,14 @@ class Runner:
|
||||
"email",
|
||||
"firstName",
|
||||
"lastName",
|
||||
"fullName",
|
||||
"level",
|
||||
"geniusLevel",
|
||||
"verified",
|
||||
"approved",
|
||||
"dateCreated",
|
||||
"dateVerified",
|
||||
"dateApproved",
|
||||
"role",
|
||||
"roles",
|
||||
"permissions",
|
||||
@@ -185,6 +197,9 @@ class Runner:
|
||||
if k in raw
|
||||
}
|
||||
)
|
||||
if self.client.permissions is not None:
|
||||
account.profile = {**account.profile, "permissions": self.client.permissions}
|
||||
account.profile = {**account.profile, "usage": usage}
|
||||
account.connection_status, account.connection_error = "connected", None
|
||||
account.verification_url, account.last_synced_at = None, now()
|
||||
await db.execute(
|
||||
|
||||
Reference in New Issue
Block a user