47 lines
1.5 KiB
Python
47 lines
1.5 KiB
Python
from typing import Any, Dict
|
|
|
|
from fastapi import APIRouter, Depends
|
|
|
|
from ..auth import get_current_user
|
|
from ..build_info import BUILD_NUMBER, CHANGELOG
|
|
from ..runtime import get_runtime_settings
|
|
|
|
router = APIRouter(prefix="/site", tags=["site"])
|
|
|
|
_BANNER_TONES = {"info", "warning", "error", "maintenance"}
|
|
|
|
|
|
def _build_site_info(include_changelog: bool) -> Dict[str, Any]:
|
|
runtime = get_runtime_settings()
|
|
banner_message = (runtime.site_banner_message or "").strip()
|
|
tone = (runtime.site_banner_tone or "info").strip().lower()
|
|
if tone not in _BANNER_TONES:
|
|
tone = "info"
|
|
info = {
|
|
"buildNumber": (runtime.site_build_number or BUILD_NUMBER or "").strip(),
|
|
"banner": {
|
|
"enabled": bool(runtime.site_banner_enabled and banner_message),
|
|
"message": banner_message,
|
|
"tone": tone,
|
|
},
|
|
"login": {
|
|
"showJellyfinLogin": bool(runtime.site_login_show_jellyfin_login),
|
|
"showLocalLogin": bool(runtime.site_login_show_local_login),
|
|
"showForgotPassword": bool(runtime.site_login_show_forgot_password),
|
|
"showSignupLink": bool(runtime.site_login_show_signup_link),
|
|
},
|
|
}
|
|
if include_changelog:
|
|
info["changelog"] = (CHANGELOG or "").strip()
|
|
return info
|
|
|
|
|
|
@router.get("/public")
|
|
async def site_public() -> Dict[str, Any]:
|
|
return _build_site_info(False)
|
|
|
|
|
|
@router.get("/info")
|
|
async def site_info(user: Dict[str, Any] = Depends(get_current_user)) -> Dict[str, Any]:
|
|
return _build_site_info(True)
|