fix for latest fastapi

This commit is contained in:
dni ⚡ 2023-06-21 11:08:07 +02:00
commit f41c3f4044
No known key found for this signature in database
GPG key ID: 886317704CC4E618
2 changed files with 6 additions and 5 deletions

View file

@ -31,7 +31,7 @@ from .nxp424 import decryptSUN, getSunMAC
# /boltcards/api/v1/scan?p=00000000000000000000000000000000&c=0000000000000000 # /boltcards/api/v1/scan?p=00000000000000000000000000000000&c=0000000000000000
@boltcards_ext.get("/api/v1/scan/{external_id}") @boltcards_ext.get("/api/v1/scan/{external_id}")
async def api_scan(p, c, request: Request, external_id: str = Query(None)): async def api_scan(p, c, request: Request, external_id: str):
# some wallets send everything as lower case, no bueno # some wallets send everything as lower case, no bueno
p = p.upper() p = p.upper()
c = c.upper() c = c.upper()
@ -75,7 +75,7 @@ async def api_scan(p, c, request: Request, external_id: str = Query(None)):
if hits_amount > card.daily_limit: if hits_amount > card.daily_limit:
return {"status": "ERROR", "reason": "Max daily limit spent."} return {"status": "ERROR", "reason": "Max daily limit spent."}
hit = await create_hit(card.id, ip, agent, card.counter, ctr_int) hit = await create_hit(card.id, ip, agent, card.counter, ctr_int)
lnurlpay = lnurl_encode(request.url_for("boltcards.lnurlp_response", hit_id=hit.id)) lnurlpay = lnurl_encode(str(request.url_for("boltcards.lnurlp_response", hit_id=hit.id)))
return { return {
"tag": "withdrawRequest", "tag": "withdrawRequest",
"callback": request.url_for("boltcards.lnurl_callback", hitid=hit.id), "callback": request.url_for("boltcards.lnurl_callback", hitid=hit.id),
@ -175,7 +175,7 @@ async def api_auth(a, request: Request):
response_class=HTMLResponse, response_class=HTMLResponse,
name="boltcards.lnurlp_response", name="boltcards.lnurlp_response",
) )
async def lnurlp_response(req: Request, hit_id: str = Query(None)): async def lnurlp_response(req: Request, hit_id: str):
hit = await get_hit(hit_id) hit = await get_hit(hit_id)
assert hit assert hit
card = await get_card(hit.card_id) card = await get_card(hit.card_id)
@ -199,7 +199,7 @@ async def lnurlp_response(req: Request, hit_id: str = Query(None)):
response_class=HTMLResponse, response_class=HTMLResponse,
name="boltcards.lnurlp_callback", name="boltcards.lnurlp_callback",
) )
async def lnurlp_callback(hit_id: str = Query(None), amount: str = Query(None)): async def lnurlp_callback(hit_id: str, amount: str = Query(None)):
hit = await get_hit(hit_id) hit = await get_hit(hit_id)
assert hit assert hit
card = await get_card(hit.card_id) card = await get_card(hit.card_id)

View file

@ -1,4 +1,5 @@
from http import HTTPStatus from http import HTTPStatus
from typing import Optional
from fastapi import Depends, HTTPException, Query from fastapi import Depends, HTTPException, Query
@ -37,7 +38,7 @@ async def api_cards(
@boltcards_ext.put("/api/v1/cards/{card_id}", status_code=HTTPStatus.OK) @boltcards_ext.put("/api/v1/cards/{card_id}", status_code=HTTPStatus.OK)
async def api_card_create_or_update( async def api_card_create_or_update(
data: CreateCardData, data: CreateCardData,
card_id: str = Query(None), card_id: Optional[str],
wallet: WalletTypeInfo = Depends(require_admin_key), wallet: WalletTypeInfo = Depends(require_admin_key),
): ):
try: try: