feat: extension entrypoint wiring
Ties the layers together: router prefix, static mount, and the permanent tasks (invoice listener + hold-expiry). Inbound Nostr subscription is wired-but-commented pending relay plumbing. Extension is now loadable. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019VUQCfdqiLSsFS2jcGnaFD
This commit is contained in:
parent
43cfa5d921
commit
910c284a7d
1 changed files with 52 additions and 0 deletions
52
__init__.py
Normal file
52
__init__.py
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
import asyncio
|
||||||
|
|
||||||
|
from fastapi import APIRouter
|
||||||
|
|
||||||
|
from .crud import db
|
||||||
|
from .tasks import expire_holds_loop, wait_for_paid_invoices
|
||||||
|
from .views import chatelet_generic_router
|
||||||
|
from .views_api import chatelet_api_router
|
||||||
|
|
||||||
|
chatelet_static_files = [
|
||||||
|
{
|
||||||
|
"path": "/chatelet/static",
|
||||||
|
"name": "chatelet_static",
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
chatelet_ext: APIRouter = APIRouter(prefix="/chatelet", tags=["chatelet"])
|
||||||
|
chatelet_ext.include_router(chatelet_generic_router)
|
||||||
|
chatelet_ext.include_router(chatelet_api_router)
|
||||||
|
|
||||||
|
scheduled_tasks: list[asyncio.Task] = []
|
||||||
|
|
||||||
|
|
||||||
|
def chatelet_stop():
|
||||||
|
for task in scheduled_tasks:
|
||||||
|
task.cancel()
|
||||||
|
|
||||||
|
|
||||||
|
def chatelet_start():
|
||||||
|
from lnbits.tasks import create_permanent_unique_task
|
||||||
|
|
||||||
|
scheduled_tasks.append(
|
||||||
|
create_permanent_unique_task("chatelet_invoices", wait_for_paid_invoices)
|
||||||
|
)
|
||||||
|
scheduled_tasks.append(
|
||||||
|
create_permanent_unique_task("chatelet_hold_expiry", expire_holds_loop)
|
||||||
|
)
|
||||||
|
# TODO(relay): once relay plumbing lands, also start the inbound Nostr
|
||||||
|
# subscription so guests can query availability + book over Nostr:
|
||||||
|
# from .nostr.service import subscribe_inbound
|
||||||
|
# scheduled_tasks.append(
|
||||||
|
# create_permanent_unique_task("chatelet_nostr_in", subscribe_inbound)
|
||||||
|
# )
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"db",
|
||||||
|
"chatelet_ext",
|
||||||
|
"chatelet_start",
|
||||||
|
"chatelet_static_files",
|
||||||
|
"chatelet_stop",
|
||||||
|
]
|
||||||
Loading…
Add table
Add a link
Reference in a new issue