fix api register bug

This commit is contained in:
jxxghp
2025-05-13 20:52:22 +08:00
parent 30de524319
commit 7be2910809
2 changed files with 12 additions and 4 deletions
+4
View File
@@ -5,8 +5,10 @@ from sqlalchemy.orm import Session
from starlette.background import BackgroundTasks from starlette.background import BackgroundTasks
from app import schemas from app import schemas
from app.api.endpoints.plugin import register_plugin_api
from app.chain.site import SiteChain from app.chain.site import SiteChain
from app.chain.torrents import TorrentsChain from app.chain.torrents import TorrentsChain
from app.command import Command
from app.core.event import EventManager from app.core.event import EventManager
from app.core.plugin import PluginManager from app.core.plugin import PluginManager
from app.core.security import verify_token from app.core.security import verify_token
@@ -388,6 +390,8 @@ def auth_site(
# 认证成功后,重新初始化插件 # 认证成功后,重新初始化插件
PluginManager().init_config() PluginManager().init_config()
Scheduler().init_plugin_jobs() Scheduler().init_plugin_jobs()
Command().init_commands()
register_plugin_api()
return schemas.Response(success=status, message=msg) return schemas.Response(success=status, message=msg)
+8 -4
View File
@@ -51,6 +51,8 @@ class Scheduler(metaclass=Singleton):
_jobs = {} _jobs = {}
# 用户认证失败次数 # 用户认证失败次数
_auth_count = 0 _auth_count = 0
# 用户认证失败消息发送
_auth_message = False
def __init__(self): def __init__(self):
self.init() self.init()
@@ -661,9 +663,11 @@ class Scheduler(metaclass=Singleton):
# 最大重试次数 # 最大重试次数
__max_try__ = 30 __max_try__ = 30
if self._auth_count > __max_try__: if self._auth_count > __max_try__:
SchedulerChain().messagehelper.put(title=f"用户认证失败", if not self._auth_message:
message="用户认证失败次数过多,将不再尝试认证!", SchedulerChain().messagehelper.put(title=f"用户认证失败",
role="system") message="用户认证失败次数过多,将不再尝试认证!",
role="system")
self._auth_message = True
return return
logger.info("用户未认证,正在尝试认证...") logger.info("用户未认证,正在尝试认证...")
auth_conf = SystemConfigOper().get(SystemConfigKey.UserSiteAuthParams) auth_conf = SystemConfigOper().get(SystemConfigKey.UserSiteAuthParams)
@@ -678,7 +682,7 @@ class Scheduler(metaclass=Singleton):
Notification( Notification(
mtype=NotificationType.Manual, mtype=NotificationType.Manual,
title="MoviePilot用户认证成功", title="MoviePilot用户认证成功",
text=f"使用站点:{msg}", text=f"使用站点:{msg},如有插件使用异常,请重启MoviePilot。",
link=settings.MP_DOMAIN('#/site') link=settings.MP_DOMAIN('#/site')
) )
) )