Merge branch 'FastAPI' of https://github.com/arcbtc/lnbits into FastAPI

This commit is contained in:
Tiago vasconcelos 2021-11-17 21:20:53 +00:00
commit 2676e136cb

View file

@ -73,8 +73,13 @@ async def displaywin(
raise HTTPException( raise HTTPException(
status_code=HTTPStatus.NOT_FOUND, detail="satsdice link does not exist." status_code=HTTPStatus.NOT_FOUND, detail="satsdice link does not exist."
) )
withdrawLink = await get_satsdice_withdraw(payment_hash) withdrawLink = await get_satsdice_withdraw(payment_hash)
payment = await get_satsdice_payment(payment_hash)
if payment.lost:
return satsdice_renderer().TemplateResponse(
"satsdice/error.html",
{"request": request, "link": satsdicelink.id, "paid": False, "lost": True},
)
if withdrawLink: if withdrawLink:
return satsdice_renderer().TemplateResponse( return satsdice_renderer().TemplateResponse(
"satsdice/displaywin.html", "satsdice/displaywin.html",
@ -92,6 +97,7 @@ async def displaywin(
chance = satsdicelink.chance chance = satsdicelink.chance
status = await api_payment(payment_hash) status = await api_payment(payment_hash)
if not rand < chance or not status["paid"]: if not rand < chance or not status["paid"]:
await update_satsdice_payment(payment_hash, lost=1)
return satsdice_renderer().TemplateResponse( return satsdice_renderer().TemplateResponse(
"satsdice/error.html", "satsdice/error.html",
{"request": request, "link": satsdicelink.id, "paid": False, "lost": True}, {"request": request, "link": satsdicelink.id, "paid": False, "lost": True},