I want them to turn black

This commit is contained in:
benarc
2021-10-17 18:33:29 +01:00
parent 70facdaa93
commit 1d3bb016a2
84 changed files with 899 additions and 1008 deletions
+26 -22
View File
@@ -28,7 +28,11 @@ from .crud import (
@withdraw_ext.get("/api/v1/links", status_code=HTTPStatus.OK)
# @api_check_wallet_key("invoice")
async def api_links(req: Request, wallet: WalletTypeInfo = Depends(get_key_type), all_wallets: bool = Query(False)):
async def api_links(
req: Request,
wallet: WalletTypeInfo = Depends(get_key_type),
all_wallets: bool = Query(False),
):
wallet_ids = [wallet.wallet.id]
if all_wallets:
@@ -36,12 +40,9 @@ async def api_links(req: Request, wallet: WalletTypeInfo = Depends(get_key_type)
try:
return [
{
**link.dict(),
**{"lnurl": link.lnurl(req)},
}
for link in await get_withdraw_links(wallet_ids)
]
{**link.dict(), **{"lnurl": link.lnurl(req)}}
for link in await get_withdraw_links(wallet_ids)
]
except LnurlInvalidUrl:
raise HTTPException(
@@ -59,21 +60,20 @@ async def api_link_retrieve(link_id, wallet: WalletTypeInfo = Depends(get_key_ty
if not link:
raise HTTPException(
detail="Withdraw link does not exist.",
status_code=HTTPStatus.NOT_FOUND
detail="Withdraw link does not exist.", status_code=HTTPStatus.NOT_FOUND
)
# response.status_code = HTTPStatus.NOT_FOUND
# return {"message": "Withdraw link does not exist."}
if link.wallet != wallet.wallet.id:
raise HTTPException(
detail="Not your withdraw link.",
status_code=HTTPStatus.FORBIDDEN
detail="Not your withdraw link.", status_code=HTTPStatus.FORBIDDEN
)
# response.status_code = HTTPStatus.FORBIDDEN
# return {"message": "Not your withdraw link."}
return {**link, **{"lnurl": link.lnurl(request)}}
# class CreateData(BaseModel):
# title: str = Query(...)
# min_withdrawable: int = Query(..., ge=1)
@@ -82,14 +82,20 @@ async def api_link_retrieve(link_id, wallet: WalletTypeInfo = Depends(get_key_ty
# wait_time: int = Query(..., ge=1)
# is_unique: bool
@withdraw_ext.post("/api/v1/links", status_code=HTTPStatus.CREATED)
@withdraw_ext.put("/api/v1/links/{link_id}", status_code=HTTPStatus.OK)
# @api_check_wallet_key("admin")
async def api_link_create_or_update(req: Request, data: CreateWithdrawData, link_id: str = None, wallet: WalletTypeInfo = Depends(get_key_type)):
async def api_link_create_or_update(
req: Request,
data: CreateWithdrawData,
link_id: str = None,
wallet: WalletTypeInfo = Depends(get_key_type),
):
if data.max_withdrawable < data.min_withdrawable:
raise HTTPException(
detail="`max_withdrawable` needs to be at least `min_withdrawable`.",
status_code=HTTPStatus.BAD_REQUEST
status_code=HTTPStatus.BAD_REQUEST,
)
# response.status_code = HTTPStatus.BAD_REQUEST
# return {
@@ -108,15 +114,13 @@ async def api_link_create_or_update(req: Request, data: CreateWithdrawData, link
link = await get_withdraw_link(link_id, 0)
if not link:
raise HTTPException(
detail="Withdraw link does not exist.",
status_code=HTTPStatus.NOT_FOUND
detail="Withdraw link does not exist.", status_code=HTTPStatus.NOT_FOUND
)
# response.status_code = HTTPStatus.NOT_FOUND
# return {"message": "Withdraw link does not exist."}
if link.wallet != wallet.wallet.id:
raise HTTPException(
detail="Not your withdraw link.",
status_code=HTTPStatus.FORBIDDEN
detail="Not your withdraw link.", status_code=HTTPStatus.FORBIDDEN
)
# response.status_code = HTTPStatus.FORBIDDEN
# return {"message": "Not your withdraw link."}
@@ -137,16 +141,14 @@ async def api_link_delete(link_id, wallet: WalletTypeInfo = Depends(get_key_type
if not link:
raise HTTPException(
detail="Withdraw link does not exist.",
status_code=HTTPStatus.NOT_FOUND
detail="Withdraw link does not exist.", status_code=HTTPStatus.NOT_FOUND
)
# response.status_code = HTTPStatus.NOT_FOUND
# return {"message": "Withdraw link does not exist."}
if link.wallet != wallet.wallet.id:
raise HTTPException(
detail="Not your withdraw link.",
status_code=HTTPStatus.FORBIDDEN
detail="Not your withdraw link.", status_code=HTTPStatus.FORBIDDEN
)
# response.status_code = HTTPStatus.FORBIDDEN
# return {"message": "Not your withdraw link."}
@@ -158,6 +160,8 @@ async def api_link_delete(link_id, wallet: WalletTypeInfo = Depends(get_key_type
@withdraw_ext.get("/api/v1/links/{the_hash}/{lnurl_id}", status_code=HTTPStatus.OK)
# @api_check_wallet_key("invoice")
async def api_hash_retrieve(the_hash, lnurl_id, wallet: WalletTypeInfo = Depends(get_key_type)):
async def api_hash_retrieve(
the_hash, lnurl_id, wallet: WalletTypeInfo = Depends(get_key_type)
):
hashCheck = await get_hash_check(the_hash, lnurl_id)
return hashCheck