diff --git a/lnbits/app.py b/lnbits/app.py index b1312fd8c..8cf44469a 100644 --- a/lnbits/app.py +++ b/lnbits/app.py @@ -155,14 +155,7 @@ def register_new_ext_routes(app: FastAPI) -> Callable: def register_ext_routes(app: FastAPI, ext: Extension) -> None: """Register FastAPI routes for extension.""" - ext_module = importlib.import_module(f"lnbits.extensions.{ext.code}") - if ext.version != "": - if f"lnbits.extensions.{ext.code}" in sys.modules: - del sys.modules[f"lnbits.extensions.{ext.code}"] - del ext_module - ext_module = importlib.import_module(f"lnbits.upgrades.{ext.version}.{ext.code}-{ext.version}") - # else: - # ext_module = importlib.import_module(f"lnbits.extensions.{ext.code}") + ext_module = importlib.import_module(ext.module_name) ext_route = getattr(ext_module, f"{ext.code}_ext") @@ -176,11 +169,9 @@ def register_ext_routes(app: FastAPI, ext: Extension) -> None: app.mount(s["path"], s["app"], s["name"]) logger.trace(f"adding route for extension {ext_module}") - if ext.version != "": - # ext_route.prefix = "/sss" - app.include_router(router=ext_route, prefix="/sss") - else: - app.include_router(router=ext_route) + + prefix = f"/upgrades/{ext.version}" if ext.version != "" else "" + app.include_router(router=ext_route, prefix=prefix) def register_startup(app: FastAPI):