mirror of
https://github.com/lnbits/lnbits.git
synced 2025-08-06 19:54:09 +02:00
copilot still not working
This commit is contained in:
@@ -11,7 +11,6 @@ async def create_copilot(
|
||||
data: CreateCopilotData, inkey: Optional[str] = ""
|
||||
) -> Copilots:
|
||||
copilot_id = urlsafe_short_hash()
|
||||
|
||||
await db.execute(
|
||||
"""
|
||||
INSERT INTO copilot.copilots (
|
||||
@@ -82,7 +81,6 @@ async def get_copilot(copilot_id: str) -> Copilots:
|
||||
|
||||
async def get_copilots(user: str) -> List[Copilots]:
|
||||
rows = await db.fetchall("SELECT * FROM copilot.copilots WHERE user = ?", (user,))
|
||||
print(user)
|
||||
return [Copilots(**row) for row in rows]
|
||||
|
||||
|
||||
|
@@ -10,29 +10,29 @@ from pydantic import BaseModel
|
||||
|
||||
|
||||
class CreateCopilotData(BaseModel):
|
||||
id: str = Query(None)
|
||||
user: str = Query(None)
|
||||
title: str = Query(None)
|
||||
lnurl_toggle: int = Query(None)
|
||||
wallet: str = Query(None)
|
||||
animation1: str = Query(None)
|
||||
animation2: str = Query(None)
|
||||
animation3: str = Query(None)
|
||||
animation1threshold: int = Query(None)
|
||||
animation2threshold: int = Query(None)
|
||||
animation3threshold: int = Query(None)
|
||||
animation1webhook: str = Query(None)
|
||||
animation2webhook: str = Query(None)
|
||||
animation3webhook: str = Query(None)
|
||||
lnurl_title: str = Query(None)
|
||||
show_message: int = Query(None)
|
||||
show_ack: int = Query(None)
|
||||
show_price: int = Query(None)
|
||||
amount_made: int = Query(None)
|
||||
timestamp: int = Query(None)
|
||||
fullscreen_cam: int = Query(None)
|
||||
iframe_url: str = Query(None)
|
||||
success_url: str = Query(None)
|
||||
id: Optional[str] = None
|
||||
user: Optional[str] = None
|
||||
title: Optional[str] = None
|
||||
lnurl_toggle: Optional[int] = None
|
||||
wallet: Optional[str] = None
|
||||
animation1: Optional[str] = None
|
||||
animation2: Optional[str] = None
|
||||
animation3: Optional[str] = None
|
||||
animation1threshold: Optional[int] = None
|
||||
animation2threshold: Optional[int] = None
|
||||
animation3threshold: Optional[int] = None
|
||||
animation1webhook: Optional[str] = None
|
||||
animation2webhook: Optional[str] = None
|
||||
animation3webhook: Optional[str] = None
|
||||
lnurl_title: Optional[str] = None
|
||||
show_message: Optional[int] = None
|
||||
show_ack: Optional[int] = None
|
||||
show_price: Optional[int] = None
|
||||
amount_made: Optional[int] = None
|
||||
timestamp: Optional[int] = None
|
||||
fullscreen_cam: Optional[int] = None
|
||||
iframe_url: Optional[int] = None
|
||||
success_url: Optional[str] = None
|
||||
|
||||
|
||||
class Copilots(BaseModel):
|
||||
|
@@ -515,9 +515,6 @@
|
||||
updatedData[property] = parseInt(data[property])
|
||||
}
|
||||
}
|
||||
console.log('updatedData')
|
||||
console.log(updatedData)
|
||||
console.log('updatedData')
|
||||
LNbits.api
|
||||
.request('POST', '/copilot/api/v1/copilot', wallet, updatedData)
|
||||
.then(function (response) {
|
||||
|
@@ -35,30 +35,16 @@ from .crud import (
|
||||
#######################COPILOT##########################
|
||||
|
||||
|
||||
@copilot_ext.post("/api/v1/copilot", response_class=HTMLResponse)
|
||||
@copilot_ext.put("/api/v1/copilot/{juke_id}", response_class=HTMLResponse)
|
||||
async def api_copilot_create_or_update(
|
||||
data: CreateCopilotData,
|
||||
copilot_id: str = Query(None),
|
||||
wallet: WalletTypeInfo = Depends(get_key_type),
|
||||
):
|
||||
print(data)
|
||||
if not copilot_id:
|
||||
copilot = await create_copilot(data, inkey=wallet.wallet.inkey)
|
||||
|
||||
return copilot, HTTPStatus.CREATED
|
||||
else:
|
||||
copilot = await update_copilot(data, copilot_id=copilot_id)
|
||||
return copilot
|
||||
|
||||
|
||||
@copilot_ext.get("/api/v1/copilot", response_class=HTMLResponse)
|
||||
async def api_copilots_retrieve(wallet: WalletTypeInfo = Depends(get_key_type)):
|
||||
try:
|
||||
print(wallet.wallet.user)
|
||||
return [copilot.dict() for copilot in await get_copilots(wallet.wallet.user)]
|
||||
except:
|
||||
return ""
|
||||
wallet_user = wallet.wallet.user
|
||||
copilots = [copilot.dict() for copilot in await get_copilots(wallet_user)]
|
||||
if copilots:
|
||||
return copilots
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.NO_CONTENT,
|
||||
detail="No Jukeboxes",
|
||||
)
|
||||
|
||||
|
||||
@copilot_ext.get("/api/v1/copilot/{copilot_id}", response_class=HTMLResponse)
|
||||
@@ -76,6 +62,24 @@ async def api_copilot_retrieve(
|
||||
return {**copilot.dict(), **{"lnurl": copilot.lnurl}}
|
||||
|
||||
|
||||
@copilot_ext.post("/api/v1/copilot", response_class=HTMLResponse)
|
||||
@copilot_ext.put("/api/v1/copilot/{juke_id}", response_class=HTMLResponse)
|
||||
async def api_copilot_create_or_update(
|
||||
data: CreateCopilotData,
|
||||
copilot_id: str = Query(None),
|
||||
wallet: WalletTypeInfo = Depends(get_key_type),
|
||||
):
|
||||
print("cunt")
|
||||
|
||||
if not copilot_id:
|
||||
copilot = await create_copilot(data, inkey=wallet.wallet.inkey)
|
||||
|
||||
return copilot, HTTPStatus.CREATED
|
||||
else:
|
||||
copilot = await update_copilot(data, copilot_id=copilot_id)
|
||||
return copilot, HTTPStatus.NOT_FOUND
|
||||
|
||||
|
||||
@copilot_ext.delete("/api/v1/copilot/{copilot_id}", response_class=HTMLResponse)
|
||||
async def api_copilot_delete(
|
||||
copilot_id: str = Query(None),
|
||||
|
@@ -39,7 +39,6 @@ async def api_get_jukeboxs(
|
||||
wallet_user = wallet.wallet.user
|
||||
|
||||
jukeboxs = [jukebox.dict() for jukebox in await get_jukeboxs(wallet_user)]
|
||||
print(jukeboxs)
|
||||
try:
|
||||
return jukeboxs
|
||||
|
||||
|
Reference in New Issue
Block a user