from .config import settings from .db import get_settings_overrides _INT_FIELDS = { "magent_application_port", "magent_api_port", "sonarr_quality_profile_id", "radarr_quality_profile_id", "jwt_exp_minutes", "log_file_max_bytes", "log_file_backup_count", "requests_sync_ttl_minutes", "requests_poll_interval_seconds", "requests_delta_sync_interval_minutes", "requests_cleanup_days", "magent_notify_email_smtp_port", } _BOOL_FIELDS = { "magent_proxy_enabled", "magent_proxy_trust_forwarded_headers", "magent_ssl_bind_enabled", "magent_notify_enabled", "magent_notify_email_enabled", "magent_notify_email_use_tls", "magent_notify_email_use_ssl", "magent_notify_discord_enabled", "magent_notify_telegram_enabled", "magent_notify_push_enabled", "magent_notify_webhook_enabled", "jellyfin_sync_to_arr", "site_banner_enabled", } _SKIP_OVERRIDE_FIELDS = {"site_build_number", "site_changelog"} def get_runtime_settings(): overrides = get_settings_overrides() update = {} for key, value in overrides.items(): if value is None: continue if key in _SKIP_OVERRIDE_FIELDS: continue if key in _INT_FIELDS: try: update[key] = int(value) except (TypeError, ValueError): continue elif key in _BOOL_FIELDS: if isinstance(value, bool): update[key] = value else: update[key] = str(value).strip().lower() in {"1", "true", "yes", "on"} else: update[key] = value return settings.model_copy(update=update)