mirror of
https://github.com/lnbits/lnbits.git
synced 2025-10-09 20:12:34 +02:00
copilot lnurls fetching
This commit is contained in:
@@ -23,7 +23,9 @@ from fastapi.params import Depends
|
|||||||
from fastapi.param_functions import Query
|
from fastapi.param_functions import Query
|
||||||
|
|
||||||
|
|
||||||
@copilot_ext.get("/lnurl/{cp_id}", response_class=HTMLResponse)
|
@copilot_ext.get(
|
||||||
|
"/lnurl/{cp_id}", response_class=HTMLResponse, name="copilot.lnurl_response"
|
||||||
|
)
|
||||||
async def lnurl_response(req: Request, cp_id: str = Query(None)):
|
async def lnurl_response(req: Request, cp_id: str = Query(None)):
|
||||||
cp = await get_copilot(cp_id)
|
cp = await get_copilot(cp_id)
|
||||||
if not cp:
|
if not cp:
|
||||||
|
@@ -5,6 +5,8 @@ from typing import Optional, Dict
|
|||||||
from lnbits.lnurl import encode as lnurl_encode # type: ignore
|
from lnbits.lnurl import encode as lnurl_encode # type: ignore
|
||||||
from lnurl.types import LnurlPayMetadata # type: ignore
|
from lnurl.types import LnurlPayMetadata # type: ignore
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
import json
|
||||||
|
from sqlite3 import Row
|
||||||
|
|
||||||
|
|
||||||
class CreateCopilotData(BaseModel):
|
class CreateCopilotData(BaseModel):
|
||||||
@@ -58,5 +60,5 @@ class Copilots(BaseModel):
|
|||||||
success_url: str = Query(None)
|
success_url: str = Query(None)
|
||||||
|
|
||||||
def lnurl(self, req: Request) -> str:
|
def lnurl(self, req: Request) -> str:
|
||||||
url = req.url_for("copilot.lnurl_response", link_id=self.id)
|
url = req.url_for("copilot.lnurl_response", cp_id=self.id)
|
||||||
return lnurl_encode(url)
|
return lnurl_encode(url)
|
||||||
|
@@ -49,7 +49,9 @@ async def api_copilots_retrieve(
|
|||||||
|
|
||||||
@copilot_ext.get("/api/v1/copilot/{copilot_id}")
|
@copilot_ext.get("/api/v1/copilot/{copilot_id}")
|
||||||
async def api_copilot_retrieve(
|
async def api_copilot_retrieve(
|
||||||
copilot_id: str = Query(None), wallet: WalletTypeInfo = Depends(get_key_type)
|
req: Request,
|
||||||
|
copilot_id: str = Query(None),
|
||||||
|
wallet: WalletTypeInfo = Depends(get_key_type),
|
||||||
):
|
):
|
||||||
copilot = await get_copilot(copilot_id)
|
copilot = await get_copilot(copilot_id)
|
||||||
if not copilot:
|
if not copilot:
|
||||||
@@ -58,7 +60,7 @@ async def api_copilot_retrieve(
|
|||||||
)
|
)
|
||||||
if not copilot.lnurl_toggle:
|
if not copilot.lnurl_toggle:
|
||||||
return copilot.dict()
|
return copilot.dict()
|
||||||
return {**copilot.dict(), **{"lnurl": copilot.lnurl}}
|
return {**copilot.dict(), **{"lnurl": copilot.lnurl(req)}}
|
||||||
|
|
||||||
|
|
||||||
@copilot_ext.post("/api/v1/copilot")
|
@copilot_ext.post("/api/v1/copilot")
|
||||||
|
Reference in New Issue
Block a user