mirror of
https://github.com/lnbits/lnbits.git
synced 2025-09-28 21:02:31 +02:00
make string to list
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
|
|
||||||
|
# from config import conf
|
||||||
from fastapi import Body, Depends, Request
|
from fastapi import Body, Depends, Request
|
||||||
from starlette.exceptions import HTTPException
|
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.decorators import WalletTypeInfo, require_admin_key
|
||||||
from lnbits.extensions.admin import admin_ext
|
from lnbits.extensions.admin import admin_ext
|
||||||
from lnbits.extensions.admin.models import Admin, UpdateAdminSettings
|
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
|
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(
|
raise HTTPException(
|
||||||
status_code=HTTPStatus.FORBIDDEN, detail="Not allowed: not an admin"
|
status_code=HTTPStatus.FORBIDDEN, detail="Not allowed: not an admin"
|
||||||
)
|
)
|
||||||
|
|
||||||
await update_wallet_balance(wallet_id=wallet_id, amount=int(topup_amount))
|
await update_wallet_balance(wallet_id=wallet_id, amount=int(topup_amount))
|
||||||
|
|
||||||
return {"status": "Success"}
|
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(
|
async def api_update_admin(
|
||||||
request: Request,
|
request: Request,
|
||||||
data: UpdateAdminSettings = Body(...),
|
data: UpdateAdminSettings = Body(...),
|
||||||
g: WalletTypeInfo = Depends(require_admin_key)
|
w: WalletTypeInfo = Depends(require_admin_key)
|
||||||
):
|
):
|
||||||
admin = await get_admin()
|
admin = await get_admin()
|
||||||
print(data)
|
print(data)
|
||||||
if not admin.user == g.wallet.user:
|
if not admin.user == w.wallet.user:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=HTTPStatus.FORBIDDEN, detail="Not allowed: not an admin"
|
status_code=HTTPStatus.FORBIDDEN, detail="Not allowed: not an admin"
|
||||||
)
|
)
|
||||||
updated = await update_admin(user=g.wallet.user, **data.dict())
|
updated = await update_admin(user=w.wallet.user, **data.dict())
|
||||||
print(updated)
|
|
||||||
|
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"}
|
return {"status": "Success"}
|
||||||
|
Reference in New Issue
Block a user