优化(账号自动化): 受保护账号极验重登允许按上限重试

This commit is contained in:
yml
2026-11-26 09:52:22 +08:00
parent 5a1552915e
commit 8eadb875fe
4 changed files with 163 additions and 10 deletions
+20 -5
View File
@@ -18,7 +18,10 @@ from ..models import (
)
from .account_lifecycle import DEFAULT_CK_LIFETIME, MANUAL_KINDS
from .account_protection_service import ProtectionSnapshot, load_protection_snapshot
from .account_query_filters import automation_account_filter
from .account_query_filters import (
automation_account_filter,
relogin_failure_kind_filter,
)
from .account_value import is_high_value_account, is_high_value_expr
from .douyu_service import LOGIN_ATTEMPT_IN_FLIGHT_STATUSES
@@ -256,6 +259,7 @@ def _pending_protected_invalid_query(
*,
protection: ProtectionSnapshot,
now: datetime,
max_attempts: int = 2,
):
relogin_ids = protection.relogin_ids
if not relogin_ids:
@@ -264,8 +268,9 @@ def _pending_protected_invalid_query(
Account.id.in_(relogin_ids),
Account.ck_check_status == "invalid",
automation_account_filter(cookie_operable=True),
func.coalesce(Account.relogin_failure_kind, "").notin_(
tuple(sorted(MANUAL_KINDS))
relogin_failure_kind_filter(
protected_ids=relogin_ids,
max_attempts=max_attempts,
),
or_(
Account.relogin_next_at.is_(None),
@@ -377,7 +382,12 @@ def _tier_reserve_needed(
)
p0_pending = _count_available_today(
_pending_protected_invalid_query(db, protection=protection, now=now),
_pending_protected_invalid_query(
db,
protection=protection,
now=now,
max_attempts=per_account_limit,
),
per_account_limit=per_account_limit,
quota_day=quota_day,
)
@@ -424,7 +434,12 @@ def get_login_quota_usage_summary(
per_account_limit = int(setting.per_account_daily_limit)
p0_pending = _count_available_today(
_pending_protected_invalid_query(db, protection=protection, now=moment),
_pending_protected_invalid_query(
db,
protection=protection,
now=moment,
max_attempts=per_account_limit,
),
per_account_limit=per_account_limit,
quota_day=quota_day,
)