try catch subdomain invoice_listener

This commit is contained in:
dni ⚡
2023-02-07 10:11:50 +01:00
parent e0d9f2d764
commit 2fb8eb505a

View File

@@ -1,7 +1,8 @@
import asyncio import asyncio
import httpx import httpx
from loguru import logger
from lnbits.core.models import Payment from lnbits.core.models import Payment
from lnbits.helpers import get_current_extension_name from lnbits.helpers import get_current_extension_name
from lnbits.tasks import register_invoice_listener from lnbits.tasks import register_invoice_listener
@@ -21,7 +22,7 @@ async def wait_for_paid_invoices():
async def on_invoice_paid(payment: Payment) -> None: async def on_invoice_paid(payment: Payment) -> None:
if payment.extra.get("tag") != "lnsubdomain": if payment.extra.get("tag") != "lnsubdomain":
# not an lnurlp invoice # not an lnsubdomain invoice
return return
await payment.set_pending(False) await payment.set_pending(False)
@@ -29,12 +30,19 @@ async def on_invoice_paid(payment: Payment) -> None:
domain = await get_domain(subdomain.domain) domain = await get_domain(subdomain.domain)
### Create subdomain ### Create subdomain
cf_response = await cloudflare_create_subdomain( try:
domain=domain, # type: ignore cf_response = await cloudflare_create_subdomain(
subdomain=subdomain.subdomain, domain=domain, # type: ignore
record_type=subdomain.record_type, subdomain=subdomain.subdomain,
ip=subdomain.ip, record_type=subdomain.record_type,
) ip=subdomain.ip,
)
except Exception as exc:
logger.error(exc)
logger.error("could not create subdomain on cloudflare")
return
### Use webhook to notify about cloudflare registration ### Use webhook to notify about cloudflare registration
if domain and domain.webhook: if domain and domain.webhook: