fix scrub for mypy
This commit is contained in:
parent
765fd892bf
commit
3824a108aa
|
@ -25,9 +25,9 @@ async def wait_for_paid_invoices():
|
||||||
await on_invoice_paid(payment)
|
await on_invoice_paid(payment)
|
||||||
|
|
||||||
|
|
||||||
async def on_invoice_paid(payment: Payment) -> None:
|
async def on_invoice_paid(payment: Payment):
|
||||||
# (avoid loops)
|
# (avoid loops)
|
||||||
if payment.extra.get("tag") == "scrubed":
|
if payment.extra and payment.extra.get("tag") == "scrubed":
|
||||||
# already scrubbed
|
# already scrubbed
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ async def on_invoice_paid(payment: Payment) -> None:
|
||||||
timeout=40,
|
timeout=40,
|
||||||
)
|
)
|
||||||
if r.is_error:
|
if r.is_error:
|
||||||
raise httpx.ConnectError
|
raise httpx.ConnectError("issue with scrub callback")
|
||||||
except (httpx.ConnectError, httpx.RequestError):
|
except (httpx.ConnectError, httpx.RequestError):
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=HTTPStatus.BAD_REQUEST,
|
status_code=HTTPStatus.BAD_REQUEST,
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
from fastapi import Request
|
from fastapi import Request, Depends
|
||||||
from fastapi.params import Depends
|
|
||||||
from fastapi.templating import Jinja2Templates
|
from fastapi.templating import Jinja2Templates
|
||||||
from starlette.responses import HTMLResponse
|
from starlette.responses import HTMLResponse
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
|
|
||||||
from fastapi import Request
|
from fastapi import Query, Depends
|
||||||
from fastapi.param_functions import Query
|
|
||||||
from fastapi.params import Depends
|
|
||||||
from lnurl.exceptions import InvalidUrl as LnurlInvalidUrl # type: ignore
|
|
||||||
from starlette.exceptions import HTTPException
|
from starlette.exceptions import HTTPException
|
||||||
|
|
||||||
from lnbits.core.crud import get_user
|
from lnbits.core.crud import get_user
|
||||||
|
@ -23,14 +20,14 @@ from .models import CreateScrubLink
|
||||||
|
|
||||||
@scrub_ext.get("/api/v1/links", status_code=HTTPStatus.OK)
|
@scrub_ext.get("/api/v1/links", status_code=HTTPStatus.OK)
|
||||||
async def api_links(
|
async def api_links(
|
||||||
req: Request,
|
|
||||||
wallet: WalletTypeInfo = Depends(get_key_type),
|
wallet: WalletTypeInfo = Depends(get_key_type),
|
||||||
all_wallets: bool = Query(False),
|
all_wallets: bool = Query(False),
|
||||||
):
|
):
|
||||||
wallet_ids = [wallet.wallet.id]
|
wallet_ids = [wallet.wallet.id]
|
||||||
|
|
||||||
if all_wallets:
|
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 []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return [link.dict() for link in await get_scrub_links(wallet_ids)]
|
return [link.dict() for link in await get_scrub_links(wallet_ids)]
|
||||||
|
@ -44,7 +41,7 @@ async def api_links(
|
||||||
|
|
||||||
@scrub_ext.get("/api/v1/links/{link_id}", status_code=HTTPStatus.OK)
|
@scrub_ext.get("/api/v1/links/{link_id}", status_code=HTTPStatus.OK)
|
||||||
async def api_link_retrieve(
|
async def api_link_retrieve(
|
||||||
r: Request, link_id, wallet: WalletTypeInfo = Depends(get_key_type)
|
link_id, wallet: WalletTypeInfo = Depends(get_key_type)
|
||||||
):
|
):
|
||||||
link = await get_scrub_link(link_id)
|
link = await get_scrub_link(link_id)
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,6 @@ exclude = """(?x)(
|
||||||
| ^lnbits/extensions/offlineshop.
|
| ^lnbits/extensions/offlineshop.
|
||||||
| ^lnbits/extensions/paywall.
|
| ^lnbits/extensions/paywall.
|
||||||
| ^lnbits/extensions/satspay.
|
| ^lnbits/extensions/satspay.
|
||||||
| ^lnbits/extensions/scrub.
|
|
||||||
| ^lnbits/extensions/splitpayments.
|
| ^lnbits/extensions/splitpayments.
|
||||||
| ^lnbits/extensions/streamalerts.
|
| ^lnbits/extensions/streamalerts.
|
||||||
| ^lnbits/extensions/tipjar.
|
| ^lnbits/extensions/tipjar.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user