mirror of
https://github.com/lnbits/lnbits.git
synced 2025-09-27 20:36:16 +02:00
make string to list
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from http import HTTPStatus
|
||||
|
||||
# from config import conf
|
||||
from fastapi import Body, Depends, Request
|
||||
from starlette.exceptions import HTTPException
|
||||
|
||||
@@ -7,6 +8,8 @@ from lnbits.core.crud import get_wallet
|
||||
from lnbits.decorators import WalletTypeInfo, require_admin_key
|
||||
from lnbits.extensions.admin import admin_ext
|
||||
from lnbits.extensions.admin.models import Admin, UpdateAdminSettings
|
||||
from lnbits.helpers import removeEmptyString
|
||||
from lnbits.requestvars import g
|
||||
|
||||
from .crud import get_admin, update_admin, update_wallet_balance
|
||||
|
||||
@@ -19,7 +22,7 @@ async def api_update_balance(wallet_id, topup_amount: int, g: WalletTypeInfo = D
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.FORBIDDEN, detail="Not allowed: not an admin"
|
||||
)
|
||||
|
||||
|
||||
await update_wallet_balance(wallet_id=wallet_id, amount=int(topup_amount))
|
||||
|
||||
return {"status": "Success"}
|
||||
@@ -29,14 +32,24 @@ async def api_update_balance(wallet_id, topup_amount: int, g: WalletTypeInfo = D
|
||||
async def api_update_admin(
|
||||
request: Request,
|
||||
data: UpdateAdminSettings = Body(...),
|
||||
g: WalletTypeInfo = Depends(require_admin_key)
|
||||
w: WalletTypeInfo = Depends(require_admin_key)
|
||||
):
|
||||
admin = await get_admin()
|
||||
print(data)
|
||||
if not admin.user == g.wallet.user:
|
||||
if not admin.user == w.wallet.user:
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.FORBIDDEN, detail="Not allowed: not an admin"
|
||||
)
|
||||
updated = await update_admin(user=g.wallet.user, **data.dict())
|
||||
print(updated)
|
||||
updated = await update_admin(user=w.wallet.user, **data.dict())
|
||||
|
||||
updated.admin_users = removeEmptyString(updated.admin_users.split(','))
|
||||
updated.allowed_users = removeEmptyString(updated.allowed_users.split(','))
|
||||
updated.admin_ext = removeEmptyString(updated.admin_ext.split(','))
|
||||
updated.disabled_ext = removeEmptyString(updated.disabled_ext.split(','))
|
||||
updated.theme = removeEmptyString(updated.theme.split(','))
|
||||
updated.ad_space = removeEmptyString(updated.ad_space.split(','))
|
||||
|
||||
g().admin_conf = g().admin_conf.copy(update=updated.dict())
|
||||
|
||||
print(g().admin_conf)
|
||||
return {"status": "Success"}
|
||||
|
Reference in New Issue
Block a user