fix: 修复 NewApiBalanceAction 中 Cookie 检测方式

将 Cookie 检测从 httpx client headers 检查改为 service 层注入的
_has_cookie 配置标志,解决 Cookie 在实际请求中存在但检测失败的问题
This commit is contained in:
fawney19
2026-01-20 01:36:45 +08:00
parent 24ef24558c
commit dd7cd68b51
2 changed files with 7 additions and 3 deletions

View File

@@ -125,9 +125,8 @@ class NewApiBalanceAction(BalanceAction):
site = client.base_url.host or str(client.base_url) site = client.base_url.host or str(client.base_url)
checkin_endpoint = self.config.get("checkin_endpoint", "/api/user/checkin") checkin_endpoint = self.config.get("checkin_endpoint", "/api/user/checkin")
# 检查 client 是否配置了 Cookie通过检查默认 headers # 检查是否配置了 Cookie通过 service 层注入的 _has_cookie 标志
# httpx.AsyncClient 的 headers 是 httpx.Headers 类型 has_cookie = self.config.get("_has_cookie", False)
has_cookie = "cookie" in {k.lower() for k in client.headers.keys()}
if not has_cookie: if not has_cookie:
logger.debug(f"[{site}] 未配置 Cookie跳过签到") logger.debug(f"[{site}] 未配置 Cookie跳过签到")
return None return None

View File

@@ -320,6 +320,11 @@ class ProviderOpsService:
saved_action_config = config.actions.get(action_type.value, {}).get("config", {}) saved_action_config = config.actions.get(action_type.value, {}).get("config", {})
merged_config = {**saved_action_config, **(action_config or {})} merged_config = {**saved_action_config, **(action_config or {})}
# 注入 credentials 元信息(如是否配置了 Cookie供 Action 使用
decrypted_credentials = self._decrypt_credentials(config.connector_credentials)
if decrypted_credentials.get("cookie"):
merged_config["_has_cookie"] = True
# 创建操作实例 # 创建操作实例
action = architecture.get_action(action_type, merged_config) action = architecture.get_action(action_type, merged_config)