Endpoints changed but still not working

This commit is contained in:
Ben Arc
2021-10-12 22:34:43 +01:00
parent aeee469c64
commit 1346ad12f1
9 changed files with 181 additions and 203 deletions
+29 -45
View File
@@ -1,36 +1,14 @@
from typing import List, Optional, Union
# from lnbits.db import open_ext_db
from . import db
from .models import Copilots
from .models import Copilots, CreateCopilotData
from lnbits.helpers import urlsafe_short_hash
from quart import jsonify
###############COPILOTS##########################
async def create_copilot(
title: str,
user: str,
lnurl_toggle: Optional[int] = 0,
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] = 0,
show_ack: Optional[int] = 0,
show_price: Optional[str] = None,
amount_made: Optional[int] = None,
data: CreateCopilotData, inkey: Optional[str] = ""
) -> Copilots:
copilot_id = urlsafe_short_hash()
@@ -60,24 +38,24 @@ async def create_copilot(
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
""",
(
copilot_id,
user,
int(lnurl_toggle),
wallet,
title,
animation1,
animation2,
animation3,
animation1threshold,
animation2threshold,
animation3threshold,
animation1webhook,
animation2webhook,
animation3webhook,
lnurl_title,
int(show_message),
int(show_ack),
show_price,
data.copilot_id,
data.user,
int(data.lnurl_toggle),
data.wallet,
data.title,
data.animation1,
data.animation2,
data.animation3,
data.animation1threshold,
data.animation2threshold,
data.animation3threshold,
data.animation1webhook,
data.animation2webhook,
data.animation3webhook,
data.lnurl_title,
int(data.show_message),
int(data.show_ack),
data.show_price,
0,
),
)
@@ -89,17 +67,23 @@ async def update_copilot(copilot_id: str, **kwargs) -> Optional[Copilots]:
await db.execute(
f"UPDATE copilot.copilots SET {q} WHERE id = ?", (*kwargs.values(), copilot_id)
)
row = await db.fetchone("SELECT * FROM copilot.copilots WHERE id = ?", (copilot_id,))
row = await db.fetchone(
"SELECT * FROM copilot.copilots WHERE id = ?", (copilot_id,)
)
return Copilots.from_row(row) if row else None
async def get_copilot(copilot_id: str) -> Copilots:
row = await db.fetchone("SELECT * FROM copilot.copilots WHERE id = ?", (copilot_id,))
row = await db.fetchone(
"SELECT * FROM copilot.copilots WHERE id = ?", (copilot_id,)
)
return Copilots.from_row(row) if row else None
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,)
)
return [Copilots.from_row(row) for row in rows]