feat: update to lnbits 1.0.0 (#36)
This commit is contained in:
parent
9ca714d878
commit
6714dcddc7
17 changed files with 1769 additions and 1772 deletions
26
tasks.py
26
tasks.py
|
|
@ -2,8 +2,10 @@ import asyncio
|
|||
|
||||
from lnbits.core.models import Payment
|
||||
from lnbits.tasks import register_invoice_listener
|
||||
from loguru import logger
|
||||
|
||||
from .crud import set_ticket_paid
|
||||
from .crud import get_ticket
|
||||
from .services import set_ticket_paid
|
||||
|
||||
|
||||
async def wait_for_paid_invoices():
|
||||
|
|
@ -16,12 +18,16 @@ async def wait_for_paid_invoices():
|
|||
|
||||
|
||||
async def on_invoice_paid(payment: Payment) -> None:
|
||||
# (avoid loops)
|
||||
if (
|
||||
payment.extra
|
||||
and "events" == payment.extra.get("tag")
|
||||
and payment.extra.get("name")
|
||||
and payment.extra.get("email")
|
||||
):
|
||||
await set_ticket_paid(payment.payment_hash)
|
||||
return
|
||||
if not payment.extra or "events" != payment.extra.get("tag"):
|
||||
return
|
||||
|
||||
if not payment.extra.get("name") or not payment.extra.get("email"):
|
||||
logger.warning(f"Ticket {payment.payment_hash} missing name or email.")
|
||||
return
|
||||
|
||||
ticket = await get_ticket(payment.payment_hash)
|
||||
if not ticket:
|
||||
logger.warning(f"Ticket for payment {payment.payment_hash} not found.")
|
||||
return
|
||||
|
||||
await set_ticket_paid(ticket)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue