Add files via upload
This commit is contained in:
parent
da2be43618
commit
dbb3a1a132
3 changed files with 21 additions and 6 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import asyncio
|
||||
from typing import List
|
||||
|
||||
from fastapi import APIRouter
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
|
|
@ -16,6 +17,7 @@ lnurlp_static_files = [
|
|||
"name": "lnurlp_static",
|
||||
}
|
||||
]
|
||||
scheduled_tasks: List[asyncio.Task] = []
|
||||
|
||||
lnurlp_ext: APIRouter = APIRouter(prefix="/lnurlp", tags=["lnurlp"])
|
||||
|
||||
|
|
@ -32,4 +34,5 @@ from .views_api import * # noqa: F401,F403
|
|||
|
||||
def lnurlp_start():
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.create_task(catch_everything_and_restart(wait_for_paid_invoices))
|
||||
task = loop.create_task(catch_everything_and_restart(wait_for_paid_invoices))
|
||||
scheduled_tasks.append(task)
|
||||
|
|
|
|||
|
|
@ -61,9 +61,9 @@ class PayLink(BaseModel):
|
|||
def success_action(self, payment_hash: str) -> Optional[Dict]:
|
||||
if self.success_url:
|
||||
url: ParseResult = urlparse(self.success_url)
|
||||
#qs = parse_qs(url.query)
|
||||
#setattr(qs, "payment_hash", payment_hash)
|
||||
#url = url._replace(query=urlencode(qs, doseq=True))
|
||||
# qs = parse_qs(url.query)
|
||||
# setattr(qs, "payment_hash", payment_hash)
|
||||
# url = url._replace(query=urlencode(qs, doseq=True))
|
||||
return {
|
||||
"tag": "url",
|
||||
"description": self.success_text or "~",
|
||||
|
|
|
|||
16
views_api.py
16
views_api.py
|
|
@ -1,4 +1,5 @@
|
|||
import json
|
||||
from asyncio.log import logger
|
||||
from http import HTTPStatus
|
||||
|
||||
from fastapi import Depends, Query, Request
|
||||
|
|
@ -6,10 +7,10 @@ from lnurl.exceptions import InvalidUrl as LnurlInvalidUrl
|
|||
from starlette.exceptions import HTTPException
|
||||
|
||||
from lnbits.core.crud import get_user
|
||||
from lnbits.decorators import WalletTypeInfo, get_key_type
|
||||
from lnbits.decorators import WalletTypeInfo, check_admin, get_key_type
|
||||
from lnbits.utils.exchange_rates import currencies, get_fiat_rate_satoshis
|
||||
|
||||
from . import lnurlp_ext
|
||||
from . import lnurlp_ext, scheduled_tasks
|
||||
from .crud import (
|
||||
create_pay_link,
|
||||
delete_pay_link,
|
||||
|
|
@ -166,3 +167,14 @@ async def api_check_fiat_rate(currency):
|
|||
rate = None
|
||||
|
||||
return {"rate": rate}
|
||||
|
||||
|
||||
@lnurlp_ext.delete("/api/v1", status_code=HTTPStatus.OK)
|
||||
async def api_stop(wallet: WalletTypeInfo = Depends(check_admin)):
|
||||
for t in scheduled_tasks:
|
||||
try:
|
||||
t.cancel()
|
||||
except Exception as ex:
|
||||
logger.warning(ex)
|
||||
|
||||
return {"success": True}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue