fix(douyu): 稳定绑定轮询并留档角色接口响应
This commit is contained in:
@@ -56,6 +56,7 @@ from .douyu_elite_status import (
|
||||
normalize_elite_expire_time,
|
||||
)
|
||||
from .douyu_goods_service import serialize_goods
|
||||
from .douyu_role_audit import record_role_api_candidates
|
||||
|
||||
SESSION_VALID = "valid"
|
||||
SESSION_INVALID = "invalid"
|
||||
@@ -970,10 +971,34 @@ def persist_probe_result(
|
||||
pass
|
||||
|
||||
roles = probe.get("roles") or {}
|
||||
probe_id = str(probe.get("probe_id") or "")
|
||||
task_id: int | None = None
|
||||
if probe_id.startswith("task:"):
|
||||
try:
|
||||
task_id = int(probe_id.removeprefix("task:"))
|
||||
except ValueError:
|
||||
task_id = None
|
||||
for scope in (SCOPE_ELITE, SCOPE_ESPORTS, SCOPE_PEACE):
|
||||
role = roles.get(scope)
|
||||
if isinstance(role, dict):
|
||||
_apply_role_result(account, scope, role)
|
||||
raw_candidates = [
|
||||
item
|
||||
for item in (role.get("bind_infos") or [])
|
||||
if isinstance(item, dict)
|
||||
]
|
||||
bind_info = role.get("bind_info")
|
||||
if not raw_candidates and isinstance(bind_info, dict):
|
||||
raw_candidates = [bind_info]
|
||||
record_role_api_candidates(
|
||||
db,
|
||||
account_id=account.id,
|
||||
task_id=task_id,
|
||||
candidates=raw_candidates,
|
||||
scope=scope,
|
||||
stage=f"probe.{scope}",
|
||||
source=source,
|
||||
)
|
||||
|
||||
gold = probe.get("gold") or {}
|
||||
if gold.get("status") == CAPABILITY_OK and _to_int(gold.get("balance")) is not None:
|
||||
|
||||
Reference in New Issue
Block a user