Merge branch 'master' into StreamerCopilot
This commit is contained in:
commit
b25dc51563
|
@ -84,13 +84,18 @@ async def create_usermanager_wallet(
|
|||
return wallet_created
|
||||
|
||||
|
||||
async def get_usermanager_wallet(wallet_id: str) -> Optional[Wallets]:
|
||||
async def get_usermanager_wallet(wallet_id: str) -> List[Wallets]:
|
||||
row = await db.fetchone("SELECT * FROM wallets WHERE id = ?", (wallet_id,))
|
||||
return Wallets(**row) if row else None
|
||||
|
||||
|
||||
async def get_usermanager_wallets(user_id: str) -> List[Wallets]:
|
||||
rows = await db.fetchall("SELECT * FROM wallets WHERE admin = ?", (user_id,))
|
||||
async def get_usermanager_wallets(admin_id: str) -> List[Wallets]:
|
||||
rows = await db.fetchall("SELECT * FROM wallets WHERE admin = ?", (admin_id,))
|
||||
return [Wallets(**row) for row in rows]
|
||||
|
||||
|
||||
async def get_usermanager_users_wallets(user_id: str) -> List[Wallets]:
|
||||
rows = await db.fetchall("SELECT * FROM wallets WHERE user = ?", (user_id,))
|
||||
return [Wallets(**row) for row in rows]
|
||||
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ from .crud import (
|
|||
create_usermanager_wallet,
|
||||
get_usermanager_wallet,
|
||||
get_usermanager_wallets,
|
||||
get_usermanager_users_wallets,
|
||||
delete_usermanager_wallet,
|
||||
)
|
||||
from lnbits.core import update_user_extension
|
||||
|
@ -83,18 +84,6 @@ async def api_usermanager_activate_extension():
|
|||
###Wallets
|
||||
|
||||
|
||||
@usermanager_ext.route("/api/v1/wallets", methods=["GET"])
|
||||
@api_check_wallet_key(key_type="invoice")
|
||||
async def api_usermanager_wallets():
|
||||
user_id = g.wallet.user
|
||||
return (
|
||||
jsonify(
|
||||
[wallet._asdict() for wallet in await get_usermanager_wallets(user_id)]
|
||||
),
|
||||
HTTPStatus.OK,
|
||||
)
|
||||
|
||||
|
||||
@usermanager_ext.route("/api/v1/wallets", methods=["POST"])
|
||||
@api_check_wallet_key(key_type="invoice")
|
||||
@api_validate_post_request(
|
||||
|
@ -111,6 +100,18 @@ async def api_usermanager_wallets_create():
|
|||
return jsonify(user._asdict()), HTTPStatus.CREATED
|
||||
|
||||
|
||||
@usermanager_ext.route("/api/v1/wallets", methods=["GET"])
|
||||
@api_check_wallet_key(key_type="invoice")
|
||||
async def api_usermanager_wallets():
|
||||
admin_id = g.wallet.user
|
||||
return (
|
||||
jsonify(
|
||||
[wallet._asdict() for wallet in await get_usermanager_wallets(admin_id)]
|
||||
),
|
||||
HTTPStatus.OK,
|
||||
)
|
||||
|
||||
|
||||
@usermanager_ext.route("/api/v1/wallets<wallet_id>", methods=["GET"])
|
||||
@api_check_wallet_key(key_type="invoice")
|
||||
async def api_usermanager_wallet_transactions(wallet_id):
|
||||
|
@ -119,10 +120,11 @@ async def api_usermanager_wallet_transactions(wallet_id):
|
|||
|
||||
@usermanager_ext.route("/api/v1/wallets/<user_id>", methods=["GET"])
|
||||
@api_check_wallet_key(key_type="invoice")
|
||||
async def api_usermanager_wallet(user_id):
|
||||
wallet = await get_usermanager_wallets(user_id)
|
||||
async def api_usermanager_users_wallets(user_id):
|
||||
wallet = await get_usermanager_users_wallets(user_id)
|
||||
return jsonify(wallet._asdict()), HTTPStatus.OK
|
||||
|
||||
|
||||
@usermanager_ext.route("/api/v1/wallets/<wallet_id>", methods=["DELETE"])
|
||||
@api_check_wallet_key(key_type="invoice")
|
||||
async def api_usermanager_wallets_delete(wallet_id):
|
||||
|
|
Loading…
Reference in New Issue
Block a user