Fix Webhooks on withdraw (#2)

* make webhook toggle not undefined
* undefined toggle at update and stringify webhook
* remove comment
* remove json stringify
* json validation serverside
* Fix updating withdraw links with webhook info
* make webhook toggle not undefined
* undefined toggle at update and stringify webhook
* remove comment
* remove json stringify
* Fix updating withdraw links with webhook info
* fix: use arrow functions

---------

Co-authored-by: dni  <office@dnilabs.com>
Co-authored-by: Vlad Stan <stan.v.vlad@gmail.com>
This commit is contained in:
Tiago Vasconcelos 2023-09-24 18:29:25 +01:00 committed by GitHub
commit c4cb176f10
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 26 deletions

View file

@ -1,5 +1,6 @@
from http import HTTPStatus
from typing import Optional
import json
from fastapi import Depends, HTTPException, Query, Request
from lnurl.exceptions import InvalidUrl as LnurlInvalidUrl
@ -84,6 +85,24 @@ async def api_link_create_or_update(
status_code=HTTPStatus.BAD_REQUEST,
)
if data.webhook_body:
try:
json.loads(data.webhook_body)
except:
raise HTTPException(
detail="`webhook_body` can not parse JSON.",
status_code=HTTPStatus.BAD_REQUEST,
)
if data.webhook_headers:
try:
json.loads(data.webhook_headers)
except:
raise HTTPException(
detail="`webhook_headers` can not parse JSON.",
status_code=HTTPStatus.BAD_REQUEST,
)
if link_id:
link = await get_withdraw_link(link_id, 0)
if not link: