diff --git a/lnbits/extensions/bleskomat/crud.py b/lnbits/extensions/bleskomat/crud.py index b85477b4d..206cec1f6 100644 --- a/lnbits/extensions/bleskomat/crud.py +++ b/lnbits/extensions/bleskomat/crud.py @@ -106,7 +106,7 @@ async def create_bleskomat_lnurl( return bleskomat_lnurl -async def get_bleskomat_lnurl(secret: str) -> BleskomatLnurl: +async def get_bleskomat_lnurl(secret: str) -> Optional[BleskomatLnurl]: hash = generate_bleskomat_lnurl_hash(secret) row = await db.fetchone("SELECT * FROM bleskomat_lnurls WHERE hash = ?", (hash,)) return BleskomatLnurl(**row) if row else None diff --git a/lnbits/extensions/bleskomat/models.py b/lnbits/extensions/bleskomat/models.py index cec138e6f..54633146d 100644 --- a/lnbits/extensions/bleskomat/models.py +++ b/lnbits/extensions/bleskomat/models.py @@ -91,8 +91,8 @@ class BleskomatLnurl(NamedTuple): wallet_id=self.wallet, payment_request=query["pr"], ) - except Exception as exc: - raise LnurlValidationError(f"Failed to pay invoice: {exc.message}") + except Exception: + raise LnurlValidationError("Failed to pay invoice") if not payment_hash: raise LnurlValidationError("Failed to pay invoice") diff --git a/lnbits/extensions/lnticket/crud.py b/lnbits/extensions/lnticket/crud.py index 6c39afb88..ed8c22710 100644 --- a/lnbits/extensions/lnticket/crud.py +++ b/lnbits/extensions/lnticket/crud.py @@ -55,24 +55,25 @@ async def set_ticket_paid(payment_hash: str) -> Tickets: ) ticket = await get_ticket(payment_hash) + assert ticket, "Newly paid ticket could not be retrieved" + if formdata.webhook: async with httpx.AsyncClient() as client: - try: - r = await client.post( - formdata.webhook, - json={ - "form": ticket.form, - "name": ticket.name, - "email": ticket.email, - "content": ticket.ltext, - }, - timeout=40, - ) - except AssertionError: - webhook = None + await client.post( + formdata.webhook, + json={ + "form": ticket.form, + "name": ticket.name, + "email": ticket.email, + "content": ticket.ltext, + }, + timeout=40, + ) return ticket + ticket = await get_ticket(payment_hash) - return + assert ticket, "Newly paid ticket could not be retrieved" + return ticket async def get_ticket(ticket_id: str) -> Optional[Tickets]: diff --git a/lnbits/extensions/subdomains/crud.py b/lnbits/extensions/subdomains/crud.py index e64d4cd69..6e2c2e7e4 100644 --- a/lnbits/extensions/subdomains/crud.py +++ b/lnbits/extensions/subdomains/crud.py @@ -4,7 +4,6 @@ from lnbits.helpers import urlsafe_short_hash from . import db from .models import Domains, Subdomains -from lnbits.extensions import subdomains async def create_subdomain( @@ -37,9 +36,9 @@ async def create_subdomain( ), ) - subdomain = await get_subdomain(payment_hash) - assert subdomain, "Newly created subdomain couldn't be retrieved" - return subdomain + new_subdomain = await get_subdomain(payment_hash) + assert new_subdomain, "Newly created subdomain couldn't be retrieved" + return new_subdomain async def set_subdomain_paid(payment_hash: str) -> Subdomains: @@ -70,8 +69,9 @@ async def set_subdomain_paid(payment_hash: str) -> Subdomains: (amount, row[1]), ) - subdomain = await get_subdomain(payment_hash) - return subdomain + new_subdomain = await get_subdomain(payment_hash) + assert new_subdomain, "Newly paid subdomain couldn't be retrieved" + return new_subdomain async def get_subdomain(subdomain_id: str) -> Optional[Subdomains]: @@ -79,7 +79,6 @@ async def get_subdomain(subdomain_id: str) -> Optional[Subdomains]: "SELECT s.*, d.domain as domain_name FROM subdomain s INNER JOIN domain d ON (s.domain = d.id) WHERE s.id = ?", (subdomain_id,), ) - print(row) return Subdomains(**row) if row else None @@ -143,9 +142,9 @@ async def create_domain( ), ) - domain = await get_domain(domain_id) - assert domain, "Newly created domain couldn't be retrieved" - return domain + new_domain = await get_domain(domain_id) + assert new_domain, "Newly created domain couldn't be retrieved" + return new_domain async def update_domain(domain_id: str, **kwargs) -> Domains: