fix events for mypy
This commit is contained in:
parent
765fd892bf
commit
dd645f8822
|
@ -1,15 +1,6 @@
|
|||
import asyncio
|
||||
import json
|
||||
from http import HTTPStatus
|
||||
from urllib.parse import urlparse
|
||||
|
||||
import httpx
|
||||
from fastapi import HTTPException
|
||||
from loguru import logger
|
||||
|
||||
from lnbits import bolt11
|
||||
from lnbits.core.models import Payment
|
||||
from lnbits.core.services import pay_invoice
|
||||
from lnbits.extensions.events.models import CreateTicket
|
||||
from lnbits.helpers import get_current_extension_name
|
||||
from lnbits.tasks import register_invoice_listener
|
||||
|
@ -29,11 +20,17 @@ async def wait_for_paid_invoices():
|
|||
async def on_invoice_paid(payment: Payment) -> None:
|
||||
# (avoid loops)
|
||||
if (
|
||||
"events" == payment.extra.get("tag")
|
||||
payment.extra
|
||||
and "events" == payment.extra.get("tag")
|
||||
and payment.extra.get("name")
|
||||
and payment.extra.get("email")
|
||||
):
|
||||
CreateTicket.name = str(payment.extra.get("name"))
|
||||
CreateTicket.email = str(payment.extra.get("email"))
|
||||
await api_ticket_send_ticket(payment.memo, payment.payment_hash, CreateTicket)
|
||||
await api_ticket_send_ticket(
|
||||
payment.memo,
|
||||
payment.payment_hash,
|
||||
CreateTicket(
|
||||
name=str(payment.extra.get("name")),
|
||||
email=str(payment.extra.get("email")),
|
||||
),
|
||||
)
|
||||
return
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
from datetime import date, datetime
|
||||
from http import HTTPStatus
|
||||
|
||||
from fastapi import Request
|
||||
from fastapi.params import Depends
|
||||
from fastapi import Depends, Request
|
||||
from fastapi.templating import Jinja2Templates
|
||||
from starlette.exceptions import HTTPException
|
||||
from starlette.responses import HTMLResponse
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
from http import HTTPStatus
|
||||
|
||||
from fastapi.param_functions import Query
|
||||
from fastapi.params import Depends
|
||||
from loguru import logger
|
||||
from fastapi import Depends, Query
|
||||
from starlette.exceptions import HTTPException
|
||||
from starlette.requests import Request
|
||||
|
||||
from lnbits.core.crud import get_user
|
||||
from lnbits.core.services import create_invoice
|
||||
|
@ -38,7 +35,8 @@ async def api_events(
|
|||
wallet_ids = [wallet.wallet.id]
|
||||
|
||||
if all_wallets:
|
||||
wallet_ids = (await get_user(wallet.wallet.user)).wallet_ids
|
||||
user = await get_user(wallet.wallet.user)
|
||||
wallet_ids = user.wallet_ids if user else []
|
||||
|
||||
return [event.dict() for event in await get_events(wallet_ids)]
|
||||
|
||||
|
@ -92,7 +90,8 @@ async def api_tickets(
|
|||
wallet_ids = [wallet.wallet.id]
|
||||
|
||||
if all_wallets:
|
||||
wallet_ids = (await get_user(wallet.wallet.user)).wallet_ids
|
||||
user = await get_user(wallet.wallet.user)
|
||||
wallet_ids = user.wallet_ids if user else []
|
||||
|
||||
return [ticket.dict() for ticket in await get_tickets(wallet_ids)]
|
||||
|
||||
|
@ -119,6 +118,11 @@ async def api_ticket_make_ticket(event_id, name, email):
|
|||
@events_ext.post("/api/v1/tickets/{event_id}/{payment_hash}")
|
||||
async def api_ticket_send_ticket(event_id, payment_hash, data: CreateTicket):
|
||||
event = await get_event(event_id)
|
||||
if not event:
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.NOT_FOUND,
|
||||
detail=f"Event could not be fetched.",
|
||||
)
|
||||
try:
|
||||
status = await api_payment(payment_hash)
|
||||
if status["paid"]:
|
||||
|
@ -129,7 +133,6 @@ async def api_ticket_send_ticket(event_id, payment_hash, data: CreateTicket):
|
|||
name=data.name,
|
||||
email=data.email,
|
||||
)
|
||||
|
||||
if not ticket:
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.NOT_FOUND,
|
||||
|
|
|
@ -92,7 +92,6 @@ exclude = """(?x)(
|
|||
^lnbits/extensions/bleskomat.
|
||||
| ^lnbits/extensions/boltz.
|
||||
| ^lnbits/extensions/boltcards.
|
||||
| ^lnbits/extensions/events.
|
||||
| ^lnbits/extensions/gerty.
|
||||
| ^lnbits/extensions/hivemind.
|
||||
| ^lnbits/extensions/invoices.
|
||||
|
|
Loading…
Reference in New Issue
Block a user