Crud webhook amount (#474)

* get_standalone_payment selects only incoming tx
This commit is contained in:
calle
2021-12-28 14:05:25 +00:00
committed by GitHub
parent 93e58f4c80
commit 32ea1106f9
2 changed files with 20 additions and 14 deletions
+5 -3
View File
@@ -30,7 +30,8 @@ async def get_account(
user_id: str, conn: Optional[Connection] = None
) -> Optional[User]:
row = await (conn or db).fetchone(
"SELECT id, email, pass as password FROM accounts WHERE id = ?", (user_id,)
"SELECT id, email, pass as password FROM accounts WHERE id = ?", (
user_id,)
)
return User(**row) if row else None
@@ -184,7 +185,7 @@ async def get_standalone_payment(
"""
SELECT *
FROM apipayments
WHERE checking_id = ? OR hash = ?
WHERE (checking_id = ? OR hash = ?) AND amount > 0 -- only the incoming payment
LIMIT 1
""",
(checking_id_or_hash, checking_id_or_hash),
@@ -304,7 +305,8 @@ async def delete_expired_invoices(conn: Optional[Connection] = None,) -> None:
except:
continue
expiration_date = datetime.datetime.fromtimestamp(invoice.date + invoice.expiry)
expiration_date = datetime.datetime.fromtimestamp(
invoice.date + invoice.expiry)
if expiration_date > datetime.datetime.utcnow():
continue