From 2fb8eb505a45fa20558279e03c239f5d2c3d2886 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dni=20=E2=9A=A1?= Date: Tue, 7 Feb 2023 10:11:50 +0100 Subject: [PATCH] try catch subdomain invoice_listener --- lnbits/extensions/subdomains/tasks.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/lnbits/extensions/subdomains/tasks.py b/lnbits/extensions/subdomains/tasks.py index aef4b49b1..fbbac88fb 100644 --- a/lnbits/extensions/subdomains/tasks.py +++ b/lnbits/extensions/subdomains/tasks.py @@ -1,7 +1,8 @@ import asyncio - import httpx +from loguru import logger + from lnbits.core.models import Payment from lnbits.helpers import get_current_extension_name 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: if payment.extra.get("tag") != "lnsubdomain": - # not an lnurlp invoice + # not an lnsubdomain invoice return await payment.set_pending(False) @@ -29,12 +30,19 @@ async def on_invoice_paid(payment: Payment) -> None: domain = await get_domain(subdomain.domain) ### Create subdomain - cf_response = await cloudflare_create_subdomain( - domain=domain, # type: ignore - subdomain=subdomain.subdomain, - record_type=subdomain.record_type, - ip=subdomain.ip, - ) + try: + cf_response = await cloudflare_create_subdomain( + domain=domain, # type: ignore + subdomain=subdomain.subdomain, + 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 if domain and domain.webhook: