Adds user settings for the Castle extension

Adds functionality to configure the Castle extension, including a wallet ID.

This allows administrators to customize the extension's behavior by specifying a dedicated wallet for castle operations.
This commit is contained in:
padreug 2025-10-22 13:55:52 +02:00
parent ceabf96f79
commit 29983cedb7
7 changed files with 199 additions and 2 deletions

View file

@ -22,6 +22,7 @@ from .crud import (
from .models import (
Account,
AccountType,
CastleSettings,
CreateAccount,
CreateEntryLine,
CreateJournalEntry,
@ -31,6 +32,7 @@ from .models import (
RevenueEntry,
UserBalance,
)
from .services import get_settings, update_settings
castle_api_router = APIRouter()
@ -450,3 +452,25 @@ async def api_pay_user(
"new_balance": balance.balance,
"message": "Payment recorded successfully",
}
# ===== SETTINGS ENDPOINTS =====
@castle_api_router.get("/api/v1/settings")
async def api_get_settings(
wallet: WalletTypeInfo = Depends(require_admin_key),
) -> CastleSettings:
"""Get Castle settings (admin only)"""
user_id = "admin"
return await get_settings(user_id)
@castle_api_router.put("/api/v1/settings")
async def api_update_settings(
data: CastleSettings,
wallet: WalletTypeInfo = Depends(require_admin_key),
) -> CastleSettings:
"""Update Castle settings (admin only)"""
user_id = "admin"
return await update_settings(user_id, data)