feat(账号): 人工标记优先于自动状态
- device_account 新增 manual_status(schema v24) - 资产总表新增「人工标记」下拉(账号异常/作品异常/账号限流/账号正常) - 有效状态 effective_status = 人工标记 or 自动状态;筛选/通知/账号池 API 都按它 - 任务自动检测只写 account_status,不覆盖人工标记 - 账号池 API 增加 manual_status/effective_status 与 ?manual= 过滤 - 测试 test_roster ⑩;文档同步
This commit is contained in:
@@ -372,6 +372,14 @@ def api_af_roster_update(row_id):
|
||||
run_id="", detected_at=time.strftime("%Y-%m-%d %H:%M:%S"),
|
||||
created_at=time.strftime("%Y-%m-%d %H:%M:%S")))
|
||||
row.account_status = new_st
|
||||
if "manual_status" in data:
|
||||
# 人工标记:和自动检测的 account_status 分开存;展示/通知/对外 API 里优先。
|
||||
# 传空串 = 清除人工标记,回落到自动状态。
|
||||
old_manual = (row.manual_status or "").strip()
|
||||
row.manual_status = (data.get("manual_status") or "").strip()[:80]
|
||||
if row.manual_status != old_manual:
|
||||
_log.info("账号人工标记:『%s』%s → %s", row.nickname,
|
||||
old_manual or "(未标记)", row.manual_status or "(清除)")
|
||||
row.updated_at = time.strftime("%Y-%m-%d %H:%M:%S")
|
||||
db.session.commit()
|
||||
_log.info("账号库编辑:%s → 昵称 %s / 设备 %s", row_id, row.nickname, row.device_name)
|
||||
@@ -444,7 +452,8 @@ def api_account_pool_accounts():
|
||||
鉴权:`X-Account-Token: <token>` 或 `Authorization: Bearer <token>`
|
||||
(令牌在「资产管理 → 🔑 账号池 API」里查看/重置)。
|
||||
|
||||
可选过滤:`?device=A11`、`?q=锋哥`、`?status=正常`、`?online=1`。
|
||||
可选过滤:`?device=A11`、`?q=锋哥`、`?status=账号异常`(按**有效状态**,
|
||||
人工标记优先)、`?manual=账号异常`(只看某个/任意人工标记)、`?online=1`。
|
||||
"""
|
||||
if request.method == "OPTIONS":
|
||||
return _pool_json({"ok": True})
|
||||
@@ -457,14 +466,23 @@ def api_account_pool_accounts():
|
||||
device = (request.args.get("device") or "").strip()
|
||||
q = (request.args.get("q") or "").strip().lower()
|
||||
status = (request.args.get("status") or "").strip()
|
||||
manual = (request.args.get("manual") or "").strip()
|
||||
only_online = (request.args.get("online") or "").strip().lower() in ("1", "true", "yes")
|
||||
rows = af.roster_rows()
|
||||
out = []
|
||||
for r in rows:
|
||||
if device and (r.get("device_name") or "") != device:
|
||||
continue
|
||||
if status and (r.get("account_status") or "") != status:
|
||||
eff = (r.get("effective_status") or r.get("account_status") or "").strip()
|
||||
if status and eff != status:
|
||||
continue
|
||||
man = (r.get("manual_status") or "").strip()
|
||||
if manual:
|
||||
if manual == "1":
|
||||
if not man:
|
||||
continue
|
||||
elif man != manual:
|
||||
continue
|
||||
if only_online and not r.get("online"):
|
||||
continue
|
||||
if q and q not in (r.get("nickname") or "").lower() \
|
||||
@@ -480,6 +498,8 @@ def api_account_pool_accounts():
|
||||
"online": bool(r.get("online")),
|
||||
"pooled": bool(r.get("pooled")),
|
||||
"account_status": r.get("account_status") or "",
|
||||
"manual_status": r.get("manual_status") or "",
|
||||
"effective_status": eff,
|
||||
"can_post_video": bool(r.get("can_post_video")),
|
||||
"note": r.get("note") or "",
|
||||
"updated_at": r.get("updated_at") or "",
|
||||
|
||||
Reference in New Issue
Block a user