2022-01-28 16:22:54 +00:00
|
|
|
import asyncio
|
2022-07-11 21:38:05 +01:00
|
|
|
from http import HTTPStatus
|
2022-01-28 16:22:54 +00:00
|
|
|
|
2022-02-10 13:54:36 +00:00
|
|
|
from fastapi import APIRouter, Request
|
2022-01-28 16:22:54 +00:00
|
|
|
from fastapi.staticfiles import StaticFiles
|
2022-02-10 13:54:36 +00:00
|
|
|
from starlette.exceptions import HTTPException
|
|
|
|
from starlette.responses import HTMLResponse
|
2022-01-27 12:24:38 +00:00
|
|
|
|
2022-07-11 21:38:05 +01:00
|
|
|
from lnbits.db import Database
|
|
|
|
from lnbits.helpers import template_renderer
|
2022-02-10 13:54:36 +00:00
|
|
|
from lnbits.settings import LNBITS_ADMIN_EXTENSIONS
|
2022-07-11 21:38:05 +01:00
|
|
|
from lnbits.tasks import catch_everything_and_restart
|
2022-01-28 16:22:54 +00:00
|
|
|
|
|
|
|
diagonalley_ext: APIRouter = APIRouter(
|
|
|
|
prefix="/diagonalley", tags=["diagonalley"]
|
2022-01-27 12:24:38 +00:00
|
|
|
)
|
2022-02-10 13:54:36 +00:00
|
|
|
db = Database("ext_diagonalley")
|
2022-07-11 21:38:05 +01:00
|
|
|
# if 'nostradmin' not in LNBITS_ADMIN_EXTENSIONS:
|
|
|
|
# @diagonalley_ext.get("/", response_class=HTMLResponse)
|
|
|
|
# async def index(request: Request):
|
|
|
|
# return template_renderer().TemplateResponse(
|
|
|
|
# "error.html", {"request": request, "err": "Ask system admin to enable NostrAdmin!"}
|
|
|
|
# )
|
|
|
|
# else:
|
|
|
|
def diagonalley_renderer():
|
|
|
|
return template_renderer(["lnbits/extensions/diagonalley/templates"])
|
2022-02-10 13:54:36 +00:00
|
|
|
|
2022-07-11 21:38:05 +01:00
|
|
|
from .tasks import wait_for_paid_invoices
|
|
|
|
from .views import * # noqa
|
|
|
|
from .views_api import * # noqa
|
2022-02-10 13:54:36 +00:00
|
|
|
|
|
|
|
|
2022-07-11 21:38:05 +01:00
|
|
|
def diagonalley_start():
|
|
|
|
loop = asyncio.get_event_loop()
|
|
|
|
loop.create_task(catch_everything_and_restart(wait_for_paid_invoices))
|