fix(通知): 账号状态按类型分别发送(不做统计)

This commit is contained in:
2026-10-21 16:44:10 +08:00
parent 677c3189c9
commit abaf65737e
7 changed files with 73 additions and 54 deletions
+17 -9
View File
@@ -218,10 +218,13 @@ print("▶ ⑧ 账号状态汇总通知(事件 account.status.summary)")
with app.app_context():
r = DeviceAccount.query.filter_by(nickname="锋哥苏州百业探访").first()
if r:
r.account_status = "正常"
r.account_status = "账号正常"
r2 = DeviceAccount.query.filter_by(nickname="周周苏州吃喝玩乐").first()
if r2:
r2.account_status = "账号异常"
r3 = DeviceAccount.query.filter_by(nickname="锋哥苏州甲探访").first()
if r3:
r3.account_status = "账号安全待提升"
db.session.commit()
notes = []
@@ -232,14 +235,19 @@ try:
ok = af.notify_account_status_summary(job_name="检测账号", source="计划运行")
finally:
_notifier.notify = _orig_notify
check("汇总函数返回 True", ok, True)
check("事件名", notes[0][0] if notes else "", "account.status.summary")
kw = notes[0][1] if notes else {}
check("总数等于账号库", kw.get("total"), len(af.roster_rows()))
check("有异常账号", (kw.get("abnormal") or 0) >= 1, True)
check("有正常账号", (kw.get("normal") or 0) >= 1, True)
check("异常清单包含具体账号",
any("周周苏州吃喝玩乐" in x for x in (kw.get("abnormal_accounts") or [])), True)
check("分类通知函数返回 True", ok, True)
check("按类型分别发送(3 类)", len(notes), 3)
check("事件名统一", {ev for ev, _ in notes}, {"account.status.summary"})
by_type = {kw.get("status_type"): kw for _, kw in notes}
ab = by_type.get("账号异常") or {}
check("账号异常标题", "账号异常" in (ab.get("title") or ""), True)
check("账号异常列表", "周周苏州吃喝玩乐" in (ab.get("accounts") or ""), True)
att = by_type.get("账号安全待提升") or {}
check("待提升列表", "锋哥苏州甲探访" in (att.get("accounts") or ""), True)
nrm = by_type.get("账号正常") or {}
check("账号正常列表", "锋哥苏州百业探访" in (nrm.get("accounts") or ""), True)
check("没有统计字段(按类型发,不做汇总)",
("total" in ab or "normal" in ab or "abnormal" in ab), False)
print()
if fails: