add fastapi 0.95 combatibility for url_for
This commit is contained in:
parent
4022faf778
commit
47f89afd4e
3 changed files with 4 additions and 3 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
__pycache__
|
||||||
4
lnurl.py
4
lnurl.py
|
|
@ -121,9 +121,9 @@ async def api_lnurl_response(request: Request, link_id, lnaddress=False):
|
||||||
if lnaddress:
|
if lnaddress:
|
||||||
# for lnaddress, we have to set this otherwise the metadata won't have the identifier
|
# for lnaddress, we have to set this otherwise the metadata won't have the identifier
|
||||||
link.domain = urlparse(str(request.url)).netloc
|
link.domain = urlparse(str(request.url)).netloc
|
||||||
callback = request.url_for("lnurlp.api_lnurl_lnaddr_callback", link_id=link.id)
|
callback = str(request.url_for("lnurlp.api_lnurl_lnaddr_callback", link_id=link.id))
|
||||||
else:
|
else:
|
||||||
callback = request.url_for("lnurlp.api_lnurl_callback", link_id=link.id)
|
callback = str(request.url_for("lnurlp.api_lnurl_callback", link_id=link.id))
|
||||||
|
|
||||||
resp = LnurlPayResponse(
|
resp = LnurlPayResponse(
|
||||||
callback=callback,
|
callback=callback,
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ class PayLink(BaseModel):
|
||||||
|
|
||||||
def lnurl(self, req: Request) -> str:
|
def lnurl(self, req: Request) -> str:
|
||||||
url = req.url_for("lnurlp.api_lnurl_response", link_id=self.id)
|
url = req.url_for("lnurlp.api_lnurl_response", link_id=self.id)
|
||||||
return lnurl_encode(url)
|
return lnurl_encode(str(url))
|
||||||
|
|
||||||
def success_action(self, payment_hash: str) -> Optional[Dict]:
|
def success_action(self, payment_hash: str) -> Optional[Dict]:
|
||||||
if self.success_url:
|
if self.success_url:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue