fix: update the in-memory settings object when the DB is updated
This commit is contained in:
parent
6252119485
commit
e28dea97d8
|
@ -408,9 +408,7 @@ async def update_wallet_balance(wallet_id: str, amount: int):
|
|||
|
||||
|
||||
async def check_admin_settings():
|
||||
|
||||
if settings.lnbits_admin_ui:
|
||||
|
||||
sets = await get_super_settings()
|
||||
if not sets:
|
||||
# create new settings if table is empty
|
||||
|
@ -422,12 +420,7 @@ async def check_admin_settings():
|
|||
sets = await get_super_settings()
|
||||
|
||||
if sets:
|
||||
for key, value in sets.dict().items():
|
||||
if not key in readonly_variables:
|
||||
try:
|
||||
setattr(settings, key, value)
|
||||
except:
|
||||
logger.error(f"error overriding setting: {key}, value: {value}")
|
||||
update_cached_settings(sets.dict())
|
||||
|
||||
# printing settings for debugging
|
||||
logger.debug(f"Admin settings:")
|
||||
|
@ -449,6 +442,15 @@ async def check_admin_settings():
|
|||
settings.send_admin_user_to_saas()
|
||||
|
||||
|
||||
def update_cached_settings(sets_dict: dict):
|
||||
for key, value in sets_dict.items():
|
||||
if not key in readonly_variables:
|
||||
try:
|
||||
setattr(settings, key, value)
|
||||
except:
|
||||
logger.error(f"error overriding setting: {key}, value: {value}")
|
||||
|
||||
|
||||
class WebsocketConnectionManager:
|
||||
def __init__(self):
|
||||
self.active_connections: List[WebSocket] = []
|
||||
|
|
|
@ -7,7 +7,7 @@ from starlette.exceptions import HTTPException
|
|||
|
||||
from lnbits.core.crud import get_wallet
|
||||
from lnbits.core.models import User
|
||||
from lnbits.core.services import update_wallet_balance
|
||||
from lnbits.core.services import update_cached_settings, update_wallet_balance
|
||||
from lnbits.decorators import check_admin
|
||||
from lnbits.server import server_restart
|
||||
from lnbits.settings import AdminSettings, EditableSetings
|
||||
|
@ -61,6 +61,7 @@ async def api_topup_balance(
|
|||
)
|
||||
async def api_update_settings(data: EditableSetings):
|
||||
await update_admin_settings(data)
|
||||
update_cached_settings(dict(data))
|
||||
return {"status": "Success"}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user