mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2025-01-19 05:33:47 +01:00
This reverts commit 1ee2d53069
.
This commit is contained in:
parent
b8922a7cd7
commit
3260acbcc7
@ -61,37 +61,25 @@ async def get_account(
|
|||||||
return User(**row) if row else None
|
return User(**row) if row else None
|
||||||
|
|
||||||
|
|
||||||
async def get_user(
|
async def get_user(user_id: str, conn: Optional[Connection] = None) -> Optional[User]:
|
||||||
user_id: str,
|
|
||||||
conn: Optional[Connection] = None,
|
|
||||||
include_deleted_wallets: Optional[bool] = False,
|
|
||||||
) -> Optional[User]:
|
|
||||||
user = await (conn or db).fetchone(
|
user = await (conn or db).fetchone(
|
||||||
"SELECT id, email FROM accounts WHERE id = ?", (user_id,)
|
"SELECT id, email FROM accounts WHERE id = ?", (user_id,)
|
||||||
)
|
)
|
||||||
|
|
||||||
if user:
|
if user:
|
||||||
clauses = ["user = ?"]
|
|
||||||
values: List[Any] = [user_id]
|
|
||||||
|
|
||||||
if not include_deleted_wallets:
|
|
||||||
clauses.append("deleted = ?")
|
|
||||||
values.append(False)
|
|
||||||
|
|
||||||
where = "WHERE " + " AND ".join(clauses) if clauses else ""
|
|
||||||
extensions = await (conn or db).fetchall(
|
extensions = await (conn or db).fetchall(
|
||||||
"""SELECT extension FROM extensions WHERE "user" = ? AND active""",
|
"""SELECT extension FROM extensions WHERE "user" = ? AND active""",
|
||||||
(user_id,),
|
(user_id,),
|
||||||
)
|
)
|
||||||
wallets = await (conn or db).fetchall(
|
wallets = await (conn or db).fetchall(
|
||||||
f"""
|
"""
|
||||||
SELECT *, COALESCE((
|
SELECT *, COALESCE((
|
||||||
SELECT balance FROM balances WHERE wallet = wallets.id
|
SELECT balance FROM balances WHERE wallet = wallets.id
|
||||||
), 0) AS balance_msat
|
), 0) AS balance_msat
|
||||||
FROM wallets
|
FROM wallets
|
||||||
{where}
|
WHERE "user" = ?
|
||||||
""",
|
""",
|
||||||
tuple(values),
|
(user_id,),
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
Loading…
Reference in New Issue
Block a user