将登录巡检能力收口到provider层
This commit is contained in:
@@ -33,7 +33,7 @@ def get_system_job_definitions(robot) -> List[Dict[str, Any]]:
|
||||
"description": "每天 14:43 执行登录二次校验",
|
||||
"trigger_type": "at_times",
|
||||
"trigger_config": {"time_list": ["14:43"]},
|
||||
"handler": robot.login_twice_auto_auth,
|
||||
"handler": _build_login_check_handler(robot),
|
||||
},
|
||||
{
|
||||
"job_key": "process_pending_images",
|
||||
@@ -75,6 +75,30 @@ def _build_contact_avatar_cache_sync_handler(robot) -> Callable[[], Awaitable[No
|
||||
return _handler
|
||||
|
||||
|
||||
def _build_login_check_handler(robot) -> Callable[[], Awaitable[bool]]:
|
||||
async def _handler() -> bool:
|
||||
ipad_bot = getattr(robot, "ipad_bot", None)
|
||||
if not ipad_bot:
|
||||
logger.info("系统任务 login_check 已跳过:wechat provider 尚未初始化")
|
||||
return False
|
||||
|
||||
login_health_check = getattr(ipad_bot, "run_login_health_check", None)
|
||||
if not callable(login_health_check):
|
||||
logger.info("系统任务 login_check 已跳过:当前 provider 未暴露登录巡检能力")
|
||||
return False
|
||||
|
||||
# 系统任务层只认 provider 统一入口:
|
||||
# 1. 这样“是否要做二次登录校验”由具体 provider 自己决定;
|
||||
# 2. Robot 不再残留 server 版本差异相关的旧方法;
|
||||
# 3. 后续新增 provider 时,只需实现自己的巡检逻辑即可接入现有调度链。
|
||||
result = login_health_check()
|
||||
if inspect.isawaitable(result):
|
||||
result = await result
|
||||
return bool(result)
|
||||
|
||||
return _handler
|
||||
|
||||
|
||||
class SystemJobLoader:
|
||||
"""系统任务加载器:从数据库读取调度配置并注册到 async_job。"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user