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

23
services.py Normal file
View file

@ -0,0 +1,23 @@
from .crud import (
create_castle_settings,
get_castle_settings,
update_castle_settings,
)
from .models import CastleSettings
async def get_settings(user_id: str) -> CastleSettings:
settings = await get_castle_settings(user_id)
if not settings:
settings = await create_castle_settings(user_id, CastleSettings())
return settings
async def update_settings(user_id: str, data: CastleSettings) -> CastleSettings:
settings = await get_castle_settings(user_id)
if not settings:
settings = await create_castle_settings(user_id, data)
else:
settings = await update_castle_settings(user_id, data)
return settings