copilot starts, templates need adjusting
This commit is contained in:
parent
1346ad12f1
commit
e1b4df869f
4 changed files with 36 additions and 25 deletions
|
|
@ -17,7 +17,6 @@ from .crud import get_copilot
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from fastapi.params import Depends
|
from fastapi.params import Depends
|
||||||
from fastapi.param_functions import Query
|
from fastapi.param_functions import Query
|
||||||
from .models import CreateJukeLinkData, CreateJukeboxPayment
|
|
||||||
|
|
||||||
|
|
||||||
@copilot_ext.get("/lnurl/{cp_id}", response_class=HTMLResponse)
|
@copilot_ext.get("/lnurl/{cp_id}", response_class=HTMLResponse)
|
||||||
|
|
|
||||||
|
|
@ -73,3 +73,15 @@ async def on_invoice_paid(payment: Payment) -> None:
|
||||||
await updater(copilot.id, data, payment.extra.get("comment"))
|
await updater(copilot.id, data, payment.extra.get("comment"))
|
||||||
else:
|
else:
|
||||||
await updater(copilot.id, data, "none")
|
await updater(copilot.id, data, "none")
|
||||||
|
|
||||||
|
|
||||||
|
async def mark_webhook_sent(payment: Payment, status: int) -> None:
|
||||||
|
payment.extra["wh_status"] = status
|
||||||
|
|
||||||
|
await core_db.execute(
|
||||||
|
"""
|
||||||
|
UPDATE apipayments SET extra = ?
|
||||||
|
WHERE hash = ?
|
||||||
|
""",
|
||||||
|
(json.dumps(payment.extra), payment.payment_hash),
|
||||||
|
)
|
||||||
|
|
|
||||||
|
|
@ -23,21 +23,21 @@ import base64
|
||||||
templates = Jinja2Templates(directory="templates")
|
templates = Jinja2Templates(directory="templates")
|
||||||
|
|
||||||
|
|
||||||
@copilot_ext.route("/", response_class=HTMLResponse)
|
@copilot_ext.get("/", response_class=HTMLResponse)
|
||||||
async def index(request: Request, user: User = Depends(check_user_exists)):
|
async def index(request: Request, user: User = Depends(check_user_exists)):
|
||||||
return copilot_renderer().TemplateResponse(
|
return copilot_renderer().TemplateResponse(
|
||||||
"copilot/index.html", {"request": request, "user": user.dict()}
|
"copilot/index.html", {"request": request, "user": user.dict()}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@copilot_ext.route("/cp/", response_class=HTMLResponse)
|
@copilot_ext.get("/cp/", response_class=HTMLResponse)
|
||||||
async def compose(request: Request):
|
async def compose(request: Request):
|
||||||
return copilot_renderer().TemplateResponse(
|
return copilot_renderer().TemplateResponse(
|
||||||
"copilot/compose.html", {"request": request}
|
"copilot/compose.html", {"request": request}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@copilot_ext.route("/pn/", response_class=HTMLResponse)
|
@copilot_ext.get("/pn/", response_class=HTMLResponse)
|
||||||
async def panel(request: Request):
|
async def panel(request: Request):
|
||||||
return copilot_renderer().TemplateResponse(
|
return copilot_renderer().TemplateResponse(
|
||||||
"copilot/panel.html", {"request": request}
|
"copilot/panel.html", {"request": request}
|
||||||
|
|
@ -52,25 +52,25 @@ async def panel(request: Request):
|
||||||
connected_websockets = defaultdict(set)
|
connected_websockets = defaultdict(set)
|
||||||
|
|
||||||
|
|
||||||
# @copilot_ext.websocket("/ws/{id}/")
|
@copilot_ext.websocket("/ws/{id}/")
|
||||||
# async def websocket_endpoint(websocket: WebSocket, id: str = Query(None)):
|
async def websocket_endpoint(websocket: WebSocket, id: str = Query(None)):
|
||||||
# copilot = await get_copilot(id)
|
copilot = await get_copilot(id)
|
||||||
# if not copilot:
|
if not copilot:
|
||||||
# return "", HTTPStatus.FORBIDDEN
|
return "", HTTPStatus.FORBIDDEN
|
||||||
# await websocket.accept()
|
await websocket.accept()
|
||||||
# invoice_queue = asyncio.Queue()
|
invoice_queue = asyncio.Queue()
|
||||||
# connected_websockets[id].add(invoice_queue)
|
connected_websockets[id].add(invoice_queue)
|
||||||
# try:
|
try:
|
||||||
# while True:
|
while True:
|
||||||
# data = await websocket.receive_text()
|
data = await websocket.receive_text()
|
||||||
# await websocket.send_text(f"Message text was: {data}")
|
await websocket.send_text(f"Message text was: {data}")
|
||||||
# finally:
|
finally:
|
||||||
# connected_websockets[id].remove(invoice_queue)
|
connected_websockets[id].remove(invoice_queue)
|
||||||
|
|
||||||
|
|
||||||
# async def updater(copilot_id, data, comment):
|
async def updater(copilot_id, data, comment):
|
||||||
# copilot = await get_copilot(copilot_id)
|
copilot = await get_copilot(copilot_id)
|
||||||
# if not copilot:
|
if not copilot:
|
||||||
# return
|
return
|
||||||
# for queue in connected_websockets[copilot_id]:
|
for queue in connected_websockets[copilot_id]:
|
||||||
# await queue.send(f"{data + '-' + comment}")
|
await queue.send(f"{data + '-' + comment}")
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ async def api_copilot_retrieve(
|
||||||
@copilot_ext.delete("/api/v1/copilot/{copilot_id}", response_class=HTMLResponse)
|
@copilot_ext.delete("/api/v1/copilot/{copilot_id}", response_class=HTMLResponse)
|
||||||
async def api_copilot_delete(
|
async def api_copilot_delete(
|
||||||
copilot_id: str = Query(None),
|
copilot_id: str = Query(None),
|
||||||
wallet: WalletTypeInfo = Depends(WalletAdminKeyChecker()),
|
wallet: WalletTypeInfo = Depends(get_key_type),
|
||||||
):
|
):
|
||||||
copilot = await get_copilot(copilot_id)
|
copilot = await get_copilot(copilot_id)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue