copilot still not working
This commit is contained in:
parent
771c7c25c1
commit
d5a4dc801f
5 changed files with 49 additions and 51 deletions
|
|
@ -11,7 +11,6 @@ async def create_copilot(
|
||||||
data: CreateCopilotData, inkey: Optional[str] = ""
|
data: CreateCopilotData, inkey: Optional[str] = ""
|
||||||
) -> Copilots:
|
) -> Copilots:
|
||||||
copilot_id = urlsafe_short_hash()
|
copilot_id = urlsafe_short_hash()
|
||||||
|
|
||||||
await db.execute(
|
await db.execute(
|
||||||
"""
|
"""
|
||||||
INSERT INTO copilot.copilots (
|
INSERT INTO copilot.copilots (
|
||||||
|
|
@ -82,7 +81,6 @@ async def get_copilot(copilot_id: str) -> Copilots:
|
||||||
|
|
||||||
async def get_copilots(user: str) -> List[Copilots]:
|
async def get_copilots(user: str) -> List[Copilots]:
|
||||||
rows = await db.fetchall("SELECT * FROM copilot.copilots WHERE user = ?", (user,))
|
rows = await db.fetchall("SELECT * FROM copilot.copilots WHERE user = ?", (user,))
|
||||||
print(user)
|
|
||||||
return [Copilots(**row) for row in rows]
|
return [Copilots(**row) for row in rows]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,29 +10,29 @@ from pydantic import BaseModel
|
||||||
|
|
||||||
|
|
||||||
class CreateCopilotData(BaseModel):
|
class CreateCopilotData(BaseModel):
|
||||||
id: str = Query(None)
|
id: Optional[str] = None
|
||||||
user: str = Query(None)
|
user: Optional[str] = None
|
||||||
title: str = Query(None)
|
title: Optional[str] = None
|
||||||
lnurl_toggle: int = Query(None)
|
lnurl_toggle: Optional[int] = None
|
||||||
wallet: str = Query(None)
|
wallet: Optional[str] = None
|
||||||
animation1: str = Query(None)
|
animation1: Optional[str] = None
|
||||||
animation2: str = Query(None)
|
animation2: Optional[str] = None
|
||||||
animation3: str = Query(None)
|
animation3: Optional[str] = None
|
||||||
animation1threshold: int = Query(None)
|
animation1threshold: Optional[int] = None
|
||||||
animation2threshold: int = Query(None)
|
animation2threshold: Optional[int] = None
|
||||||
animation3threshold: int = Query(None)
|
animation3threshold: Optional[int] = None
|
||||||
animation1webhook: str = Query(None)
|
animation1webhook: Optional[str] = None
|
||||||
animation2webhook: str = Query(None)
|
animation2webhook: Optional[str] = None
|
||||||
animation3webhook: str = Query(None)
|
animation3webhook: Optional[str] = None
|
||||||
lnurl_title: str = Query(None)
|
lnurl_title: Optional[str] = None
|
||||||
show_message: int = Query(None)
|
show_message: Optional[int] = None
|
||||||
show_ack: int = Query(None)
|
show_ack: Optional[int] = None
|
||||||
show_price: int = Query(None)
|
show_price: Optional[int] = None
|
||||||
amount_made: int = Query(None)
|
amount_made: Optional[int] = None
|
||||||
timestamp: int = Query(None)
|
timestamp: Optional[int] = None
|
||||||
fullscreen_cam: int = Query(None)
|
fullscreen_cam: Optional[int] = None
|
||||||
iframe_url: str = Query(None)
|
iframe_url: Optional[int] = None
|
||||||
success_url: str = Query(None)
|
success_url: Optional[str] = None
|
||||||
|
|
||||||
|
|
||||||
class Copilots(BaseModel):
|
class Copilots(BaseModel):
|
||||||
|
|
|
||||||
|
|
@ -515,9 +515,6 @@
|
||||||
updatedData[property] = parseInt(data[property])
|
updatedData[property] = parseInt(data[property])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log('updatedData')
|
|
||||||
console.log(updatedData)
|
|
||||||
console.log('updatedData')
|
|
||||||
LNbits.api
|
LNbits.api
|
||||||
.request('POST', '/copilot/api/v1/copilot', wallet, updatedData)
|
.request('POST', '/copilot/api/v1/copilot', wallet, updatedData)
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
|
|
|
||||||
|
|
@ -35,30 +35,16 @@ from .crud import (
|
||||||
#######################COPILOT##########################
|
#######################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)
|
@copilot_ext.get("/api/v1/copilot", response_class=HTMLResponse)
|
||||||
async def api_copilots_retrieve(wallet: WalletTypeInfo = Depends(get_key_type)):
|
async def api_copilots_retrieve(wallet: WalletTypeInfo = Depends(get_key_type)):
|
||||||
try:
|
wallet_user = wallet.wallet.user
|
||||||
print(wallet.wallet.user)
|
copilots = [copilot.dict() for copilot in await get_copilots(wallet_user)]
|
||||||
return [copilot.dict() for copilot in await get_copilots(wallet.wallet.user)]
|
if copilots:
|
||||||
except:
|
return copilots
|
||||||
return ""
|
raise HTTPException(
|
||||||
|
status_code=HTTPStatus.NO_CONTENT,
|
||||||
|
detail="No Jukeboxes",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@copilot_ext.get("/api/v1/copilot/{copilot_id}", response_class=HTMLResponse)
|
@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}}
|
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)
|
@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),
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,6 @@ async def api_get_jukeboxs(
|
||||||
wallet_user = wallet.wallet.user
|
wallet_user = wallet.wallet.user
|
||||||
|
|
||||||
jukeboxs = [jukebox.dict() for jukebox in await get_jukeboxs(wallet_user)]
|
jukeboxs = [jukebox.dict() for jukebox in await get_jukeboxs(wallet_user)]
|
||||||
print(jukeboxs)
|
|
||||||
try:
|
try:
|
||||||
return jukeboxs
|
return jukeboxs
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue