fix some of mypy complaints.
This commit is contained in:
parent
fdf4f6c1ae
commit
e38b945d5c
4 changed files with 27 additions and 27 deletions
|
|
@ -106,7 +106,7 @@ async def create_bleskomat_lnurl(
|
||||||
return 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)
|
hash = generate_bleskomat_lnurl_hash(secret)
|
||||||
row = await db.fetchone("SELECT * FROM bleskomat_lnurls WHERE hash = ?", (hash,))
|
row = await db.fetchone("SELECT * FROM bleskomat_lnurls WHERE hash = ?", (hash,))
|
||||||
return BleskomatLnurl(**row) if row else None
|
return BleskomatLnurl(**row) if row else None
|
||||||
|
|
|
||||||
|
|
@ -91,8 +91,8 @@ class BleskomatLnurl(NamedTuple):
|
||||||
wallet_id=self.wallet,
|
wallet_id=self.wallet,
|
||||||
payment_request=query["pr"],
|
payment_request=query["pr"],
|
||||||
)
|
)
|
||||||
except Exception as exc:
|
except Exception:
|
||||||
raise LnurlValidationError(f"Failed to pay invoice: {exc.message}")
|
raise LnurlValidationError("Failed to pay invoice")
|
||||||
if not payment_hash:
|
if not payment_hash:
|
||||||
raise LnurlValidationError("Failed to pay invoice")
|
raise LnurlValidationError("Failed to pay invoice")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,24 +55,25 @@ async def set_ticket_paid(payment_hash: str) -> Tickets:
|
||||||
)
|
)
|
||||||
|
|
||||||
ticket = await get_ticket(payment_hash)
|
ticket = await get_ticket(payment_hash)
|
||||||
|
assert ticket, "Newly paid ticket could not be retrieved"
|
||||||
|
|
||||||
if formdata.webhook:
|
if formdata.webhook:
|
||||||
async with httpx.AsyncClient() as client:
|
async with httpx.AsyncClient() as client:
|
||||||
try:
|
await client.post(
|
||||||
r = await client.post(
|
formdata.webhook,
|
||||||
formdata.webhook,
|
json={
|
||||||
json={
|
"form": ticket.form,
|
||||||
"form": ticket.form,
|
"name": ticket.name,
|
||||||
"name": ticket.name,
|
"email": ticket.email,
|
||||||
"email": ticket.email,
|
"content": ticket.ltext,
|
||||||
"content": ticket.ltext,
|
},
|
||||||
},
|
timeout=40,
|
||||||
timeout=40,
|
)
|
||||||
)
|
|
||||||
except AssertionError:
|
|
||||||
webhook = None
|
|
||||||
return ticket
|
return ticket
|
||||||
|
|
||||||
ticket = await get_ticket(payment_hash)
|
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]:
|
async def get_ticket(ticket_id: str) -> Optional[Tickets]:
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ from lnbits.helpers import urlsafe_short_hash
|
||||||
|
|
||||||
from . import db
|
from . import db
|
||||||
from .models import Domains, Subdomains
|
from .models import Domains, Subdomains
|
||||||
from lnbits.extensions import subdomains
|
|
||||||
|
|
||||||
|
|
||||||
async def create_subdomain(
|
async def create_subdomain(
|
||||||
|
|
@ -37,9 +36,9 @@ async def create_subdomain(
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
subdomain = await get_subdomain(payment_hash)
|
new_subdomain = await get_subdomain(payment_hash)
|
||||||
assert subdomain, "Newly created subdomain couldn't be retrieved"
|
assert new_subdomain, "Newly created subdomain couldn't be retrieved"
|
||||||
return subdomain
|
return new_subdomain
|
||||||
|
|
||||||
|
|
||||||
async def set_subdomain_paid(payment_hash: str) -> Subdomains:
|
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]),
|
(amount, row[1]),
|
||||||
)
|
)
|
||||||
|
|
||||||
subdomain = await get_subdomain(payment_hash)
|
new_subdomain = await get_subdomain(payment_hash)
|
||||||
return subdomain
|
assert new_subdomain, "Newly paid subdomain couldn't be retrieved"
|
||||||
|
return new_subdomain
|
||||||
|
|
||||||
|
|
||||||
async def get_subdomain(subdomain_id: str) -> Optional[Subdomains]:
|
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 = ?",
|
"SELECT s.*, d.domain as domain_name FROM subdomain s INNER JOIN domain d ON (s.domain = d.id) WHERE s.id = ?",
|
||||||
(subdomain_id,),
|
(subdomain_id,),
|
||||||
)
|
)
|
||||||
print(row)
|
|
||||||
return Subdomains(**row) if row else None
|
return Subdomains(**row) if row else None
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -143,9 +142,9 @@ async def create_domain(
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
domain = await get_domain(domain_id)
|
new_domain = await get_domain(domain_id)
|
||||||
assert domain, "Newly created domain couldn't be retrieved"
|
assert new_domain, "Newly created domain couldn't be retrieved"
|
||||||
return domain
|
return new_domain
|
||||||
|
|
||||||
|
|
||||||
async def update_domain(domain_id: str, **kwargs) -> Domains:
|
async def update_domain(domain_id: str, **kwargs) -> Domains:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue