feat(douyu): unify account probes and lifecycle writes
Centralize Douyu client creation, CK session probing, identity refresh, role alias resolution, capability persistence, cache and batch throttling across collaboration, fulfillment, tasks and cookie management. Add the account-name copy action in the collaboration table.
This commit is contained in:
@@ -26,8 +26,9 @@ from .account_events_service import (
|
||||
EVENT_RELOGIN_OK,
|
||||
emit,
|
||||
)
|
||||
from .account_lifecycle import on_ck_verdict, on_login_success, sync_status
|
||||
from .account_lifecycle import on_login_success, sync_status
|
||||
from .cookie_check_service import check_douyu_cookie
|
||||
from .douyu_account_probe import persist_probe_result, probe_session
|
||||
from .douyu_service import LOGIN_ATTEMPT_IN_FLIGHT_STATUSES
|
||||
from .login_failure import classify_failure, failure_kind_label, is_account_fault
|
||||
from .proxy_service import build_proxy_runtime
|
||||
@@ -495,20 +496,45 @@ class LoginBatchRunner:
|
||||
elif result.success:
|
||||
message = result.message or "登录成功"
|
||||
if self.mode == "relogin" and account is not None:
|
||||
check_result = check_douyu_cookie(result.cookie)
|
||||
# 复检结论写账号(CK 在哪,健康状态就在哪),走统一入口:
|
||||
# 写结论 + 由好变坏记事件 + 重算状态。
|
||||
on_ck_verdict(
|
||||
check_result = probe_session(
|
||||
result.cookie,
|
||||
checker=check_douyu_cookie,
|
||||
)
|
||||
detail = (
|
||||
check_result.get("detail")
|
||||
if isinstance(check_result.get("detail"), dict)
|
||||
else {}
|
||||
)
|
||||
persist_probe_result(
|
||||
worker_db,
|
||||
account,
|
||||
"valid" if check_result["valid"] else "invalid",
|
||||
detail=check_result,
|
||||
occurred_at=check_result["checked_at"],
|
||||
{
|
||||
"probe_id": f"relogin:{self.batch_id}:{task.id}",
|
||||
"identity": {
|
||||
"uid": account.uid,
|
||||
"username": account.username,
|
||||
"nickname": detail.get("nickname") or "",
|
||||
"nickname_source": "session",
|
||||
},
|
||||
"session": check_result,
|
||||
"elite": {},
|
||||
"eligibility": {},
|
||||
"roles": {},
|
||||
"gold": {},
|
||||
"goods": {},
|
||||
"errors": {},
|
||||
},
|
||||
source="login.relogin_verify",
|
||||
record_event=False,
|
||||
commit=False,
|
||||
)
|
||||
if check_result["valid"]:
|
||||
if check_result["status"] == "valid":
|
||||
message = "重新登录成功,Cookie 有效"
|
||||
else:
|
||||
message = f"重新登录成功,但 Cookie 有效性检测失败: {check_result['message']}"
|
||||
message = (
|
||||
"重新登录成功,但 Cookie 有效性检测失败: "
|
||||
f"{check_result['message']}"
|
||||
)
|
||||
# 唯一替换旧 CK 的入口:登录成功后写回账号。
|
||||
#
|
||||
# ⚠️ 必须传 **worker_db**(本线程的会话),不能传 self.db:
|
||||
|
||||
Reference in New Issue
Block a user