fix: extension DELETE call
This commit is contained in:
+13
-3
@@ -7,6 +7,7 @@ from loguru import logger
|
||||
|
||||
from lnbits.db import Connection
|
||||
from lnbits.extension_manager import Extension
|
||||
from lnbits.settings import settings
|
||||
|
||||
from . import db as core_db
|
||||
from .crud import update_migration_version
|
||||
@@ -45,10 +46,19 @@ async def run_migration(db: Connection, migrations_module: Any, current_version:
|
||||
await update_migration_version(conn, db_name, version)
|
||||
|
||||
|
||||
async def stop_extension_work(ext_id: str, user: str):
|
||||
"""Stop background workk for extension (like asyncio.Tasks, WebSockets, etc)"""
|
||||
async def stop_extension_background_work(ext_id: str, user: str):
|
||||
"""
|
||||
Stop background workk for extension (like asyncio.Tasks, WebSockets, etc)
|
||||
It tries first to call the endpoint using `http` and if ti fails it tries using `https`
|
||||
"""
|
||||
async with httpx.AsyncClient() as client:
|
||||
try:
|
||||
await client.delete(url=f"/{ext_id}/api/v1?usr={user}")
|
||||
url = f"http://{settings.host}:{settings.port}/{ext_id}/api/v1?usr={user}"
|
||||
await client.delete(url)
|
||||
except Exception as ex:
|
||||
logger.warning(ex)
|
||||
try:
|
||||
# try https
|
||||
url = f"https://{settings.host}:{settings.port}/{ext_id}/api/v1?usr={user}"
|
||||
except Exception as ex:
|
||||
logger.warning(ex)
|
||||
|
||||
Reference in New Issue
Block a user