Fix: use direct plugin module imports instead of BUILTIN_PLUGINS
This commit is contained in:
+32
-5
@@ -337,16 +337,43 @@ def create_app() -> FastAPI:
|
|||||||
# Routes are registered here (before app start); activation status
|
# Routes are registered here (before app start); activation status
|
||||||
# is enforced at runtime via require_permission and plugin checks.
|
# is enforced at runtime via require_permission and plugin checks.
|
||||||
import importlib
|
import importlib
|
||||||
from app.plugins.builtins.contracts import BUILTIN_PLUGINS
|
# Discover all built-in plugin modules and register their routes
|
||||||
for name, plugin in BUILTIN_PLUGINS.items():
|
plugin_modules = [
|
||||||
|
"app.plugins.builtins.tags",
|
||||||
|
"app.plugins.builtins.permissions",
|
||||||
|
"app.plugins.builtins.entity_links",
|
||||||
|
"app.plugins.builtins.dms",
|
||||||
|
"app.plugins.builtins.calendar",
|
||||||
|
"app.plugins.builtins.mail",
|
||||||
|
"app.plugins.builtins.report_generator",
|
||||||
|
"app.plugins.builtins.kommunikation",
|
||||||
|
"app.plugins.builtins.tasks",
|
||||||
|
"app.plugins.builtins.automation",
|
||||||
|
"app.plugins.builtins.ai_assistant",
|
||||||
|
"app.plugins.builtins.ai_proactive",
|
||||||
|
"app.plugins.builtins.ai_ui_control",
|
||||||
|
"app.plugins.builtins.mcp_client",
|
||||||
|
"app.plugins.builtins.mcp_server",
|
||||||
|
"app.plugins.builtins.system_notif",
|
||||||
|
"app.plugins.builtins.unified_search",
|
||||||
|
]
|
||||||
|
for mod_name in plugin_modules:
|
||||||
|
try:
|
||||||
|
mod = importlib.import_module(mod_name)
|
||||||
|
# Find the plugin class and get its manifest routes
|
||||||
|
for attr_name in dir(mod):
|
||||||
|
attr = getattr(mod, attr_name)
|
||||||
|
if isinstance(attr, type) and hasattr(attr, "manifest") and hasattr(attr.manifest, "routes"):
|
||||||
|
for route_def in attr.manifest.routes:
|
||||||
try:
|
try:
|
||||||
for route_def in plugin.manifest.routes:
|
|
||||||
router_module = importlib.import_module(route_def.module)
|
router_module = importlib.import_module(route_def.module)
|
||||||
router = getattr(router_module, route_def.router_attr)
|
router = getattr(router_module, route_def.router_attr)
|
||||||
app.include_router(router)
|
app.include_router(router)
|
||||||
logger.info(f"Registered plugin routes: {name} ({len(plugin.manifest.routes)} routes)")
|
except Exception:
|
||||||
|
pass
|
||||||
|
break
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
logger.error(f"Failed to register plugin routes for {name}: {exc}")
|
logger.error(f"Failed to register plugin routes for {mod_name}: {exc}")
|
||||||
# Do NOT register plugin routes here — lifespan() handles it for active plugins only
|
# Do NOT register plugin routes here — lifespan() handles it for active plugins only
|
||||||
|
|
||||||
# ── Serve frontend static files (SPA) ──────────────────────────────
|
# ── Serve frontend static files (SPA) ──────────────────────────────
|
||||||
|
|||||||
Reference in New Issue
Block a user