优化(账号自动化): 完善受保护账号重登筛选与登录配额分配
This commit is contained in:
@@ -20,7 +20,7 @@ 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,
|
||||
relogin_failure_kind_filter,
|
||||
protected_relogin_eligible_filter,
|
||||
)
|
||||
from .account_value import is_high_value_account, is_high_value_expr
|
||||
from .douyu_service import LOGIN_ATTEMPT_IN_FLIGHT_STATUSES
|
||||
@@ -102,6 +102,8 @@ def classify_login_category(
|
||||
or not account.cookie
|
||||
or account.cookie_updated_at is None
|
||||
):
|
||||
if protected and trigger_source == "automation":
|
||||
return CATEGORY_RELOGIN_PROTECTED
|
||||
return CATEGORY_ONBOARDING
|
||||
return CATEGORY_MANUAL
|
||||
|
||||
@@ -261,21 +263,15 @@ def _pending_protected_invalid_query(
|
||||
now: datetime,
|
||||
max_attempts: int = 2,
|
||||
):
|
||||
relogin_ids = protection.relogin_ids
|
||||
if not relogin_ids:
|
||||
return db.query(Account.id).filter(Account.id == -1)
|
||||
return db.query(Account.id).filter(
|
||||
Account.id.in_(relogin_ids),
|
||||
Account.ck_check_status == "invalid",
|
||||
automation_account_filter(cookie_operable=True),
|
||||
relogin_failure_kind_filter(
|
||||
protected_ids=relogin_ids,
|
||||
protected_relogin_eligible_filter(
|
||||
protected_ids=protection.relogin_ids,
|
||||
max_attempts=max_attempts,
|
||||
),
|
||||
or_(
|
||||
Account.relogin_next_at.is_(None),
|
||||
Account.relogin_next_at <= now,
|
||||
),
|
||||
now=now,
|
||||
cookie_operable=True,
|
||||
due_only=True,
|
||||
suppressed_ids=protection.suppressed_relogin_ids,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -524,7 +520,7 @@ def reserve_login_attempt(
|
||||
setting = _setting(db)
|
||||
protection = None
|
||||
is_protected = False
|
||||
if mode == "relogin" and not category:
|
||||
if not category and (mode == "relogin" or trigger_source == "automation"):
|
||||
protection = load_protection_snapshot(db)
|
||||
is_protected = int(account.id) in protection.relogin_ids
|
||||
resolved_category = classify_login_category(
|
||||
|
||||
Reference in New Issue
Block a user