swaps pos id for number

This commit is contained in:
ben 2022-12-23 22:38:19 +00:00
parent dce50105c9
commit cd6f4c909f
2 changed files with 6 additions and 4 deletions

View File

@ -11,8 +11,10 @@ from .models import createLnurldevice, lnurldevicepayment, lnurldevices
async def create_lnurldevice(
data: createLnurldevice,
) -> lnurldevices:
if data.device == "pos":
if data.device == "pos" or data.device == "atm":
lnurldevice_id = str(await get_lnurldeviceposcount())
else:
lnurldevice_id = urlsafe_short_hash()
lnurldevice_key = urlsafe_short_hash()
await db.execute(
"""
@ -82,7 +84,7 @@ async def update_lnurldevice(lnurldevice_id: str, **kwargs) -> Optional[lnurldev
async def get_lnurldeviceposcount() -> int:
row = await db.fetchall(
"SELECT * FROM lnurldevice.lnurldevices WHERE device"
"SELECT * FROM lnurldevice.lnurldevices WHERE device = ? OR device = ?", ("pos", "atm",)
)
return len(row) + 1

View File

@ -17,8 +17,8 @@ class createLnurldevice(BaseModel):
wallet: str
currency: str
device: str
profit: float
amount: int
profit: float = 0
amount: Optional[int] = 0
pin: int = 0
profit1: float = 0
amount1: int = 0