64 lines
1.7 KiB
Python
64 lines
1.7 KiB
Python
from .config import settings
|
|
from .db import get_settings_overrides
|
|
|
|
_INT_FIELDS = {
|
|
"expiry_check_interval_minutes",
|
|
"expiry_default_days",
|
|
"expiry_warning_days",
|
|
"sonarr_quality_profile_id",
|
|
"radarr_quality_profile_id",
|
|
"invite_default_profile_id",
|
|
"referral_default_uses",
|
|
"jwt_exp_minutes",
|
|
"requests_sync_ttl_minutes",
|
|
"requests_poll_interval_seconds",
|
|
"requests_delta_sync_interval_minutes",
|
|
"requests_cleanup_days",
|
|
"smtp_port",
|
|
"jellyseerr_sync_interval_minutes",
|
|
"password_min_length",
|
|
}
|
|
_BOOL_FIELDS = {
|
|
"invites_enabled",
|
|
"invites_require_captcha",
|
|
"signup_allow_referrals",
|
|
"password_require_upper",
|
|
"password_require_lower",
|
|
"password_require_number",
|
|
"password_require_symbol",
|
|
"password_reset_enabled",
|
|
"smtp_tls",
|
|
"smtp_starttls",
|
|
"notify_email_enabled",
|
|
"notify_discord_enabled",
|
|
"notify_telegram_enabled",
|
|
"notify_matrix_enabled",
|
|
"notify_pushover_enabled",
|
|
"notify_pushbullet_enabled",
|
|
"notify_gotify_enabled",
|
|
"notify_ntfy_enabled",
|
|
"jellyfin_sync_to_arr",
|
|
"jellyseerr_sync_users",
|
|
}
|
|
|
|
|
|
def get_runtime_settings():
|
|
overrides = get_settings_overrides()
|
|
update = {}
|
|
for key, value in overrides.items():
|
|
if value is None:
|
|
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)
|