From 7be2910809d06283407997562f464486ce8ab5dc Mon Sep 17 00:00:00 2001 From: jxxghp Date: Tue, 13 May 2025 20:52:22 +0800 Subject: [PATCH] fix api register bug --- app/api/endpoints/site.py | 4 ++++ app/scheduler.py | 12 ++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/api/endpoints/site.py b/app/api/endpoints/site.py index 2f22eb0c..ccbee518 100644 --- a/app/api/endpoints/site.py +++ b/app/api/endpoints/site.py @@ -5,8 +5,10 @@ from sqlalchemy.orm import Session from starlette.background import BackgroundTasks from app import schemas +from app.api.endpoints.plugin import register_plugin_api from app.chain.site import SiteChain from app.chain.torrents import TorrentsChain +from app.command import Command from app.core.event import EventManager from app.core.plugin import PluginManager from app.core.security import verify_token @@ -388,6 +390,8 @@ def auth_site( # 认证成功后,重新初始化插件 PluginManager().init_config() Scheduler().init_plugin_jobs() + Command().init_commands() + register_plugin_api() return schemas.Response(success=status, message=msg) diff --git a/app/scheduler.py b/app/scheduler.py index 8822831b..878c21df 100644 --- a/app/scheduler.py +++ b/app/scheduler.py @@ -51,6 +51,8 @@ class Scheduler(metaclass=Singleton): _jobs = {} # 用户认证失败次数 _auth_count = 0 + # 用户认证失败消息发送 + _auth_message = False def __init__(self): self.init() @@ -661,9 +663,11 @@ class Scheduler(metaclass=Singleton): # 最大重试次数 __max_try__ = 30 if self._auth_count > __max_try__: - SchedulerChain().messagehelper.put(title=f"用户认证失败", - message="用户认证失败次数过多,将不再尝试认证!", - role="system") + if not self._auth_message: + SchedulerChain().messagehelper.put(title=f"用户认证失败", + message="用户认证失败次数过多,将不再尝试认证!", + role="system") + self._auth_message = True return logger.info("用户未认证,正在尝试认证...") auth_conf = SystemConfigOper().get(SystemConfigKey.UserSiteAuthParams) @@ -678,7 +682,7 @@ class Scheduler(metaclass=Singleton): Notification( mtype=NotificationType.Manual, title="MoviePilot用户认证成功", - text=f"使用站点:{msg}", + text=f"使用站点:{msg},如有插件使用异常,请重启MoviePilot。", link=settings.MP_DOMAIN('#/site') ) )