Refactor localization files and remove Aliyun references

This commit is contained in:
2026-04-07 11:37:47 +08:00
parent 2662b494c5
commit b395cb0b98
47 changed files with 136 additions and 1311 deletions

View File

@@ -14,8 +14,8 @@ from core.security import (
decode_access_token
)
from db.database import get_db
from db.crud import get_user_by_username, get_user_by_email, create_user, change_user_password, get_user_preferences, update_user_preferences, can_user_use_local_model, can_user_use_nsfw, get_system_setting
from schemas.user import User, UserCreate, Token, PasswordChange, AliyunKeyVerifyResponse, UserPreferences, UserPreferencesResponse
from db.crud import get_user_by_username, get_user_by_email, create_user, change_user_password, get_user_preferences, update_user_preferences, can_user_use_nsfw, get_system_setting
from schemas.user import User, UserCreate, Token, PasswordChange, UserPreferences, UserPreferencesResponse
from schemas.audiobook import LLMConfigResponse
router = APIRouter(prefix="/auth", tags=["authentication"])
@@ -155,31 +155,6 @@ async def change_password(
return user
@router.get("/aliyun-key/verify", response_model=AliyunKeyVerifyResponse)
@limiter.limit("10/minute")
async def verify_aliyun_key(
request: Request,
current_user: Annotated[User, Depends(get_current_user)],
db: Session = Depends(get_db)
):
from core.security import decrypt_api_key
from core.tts_service import AliyunTTSBackend
encrypted = get_system_setting(db, "aliyun_api_key")
if not encrypted:
return AliyunKeyVerifyResponse(valid=False, message="No Aliyun API key configured")
api_key = decrypt_api_key(encrypted)
if not api_key:
return AliyunKeyVerifyResponse(valid=False, message="Failed to decrypt API key")
aliyun_backend = AliyunTTSBackend(api_key=api_key, region=settings.ALIYUN_REGION)
health = await aliyun_backend.health_check()
if health.get("available", False):
return AliyunKeyVerifyResponse(valid=True, message="Aliyun API key is valid and working")
return AliyunKeyVerifyResponse(valid=False, message="Aliyun API key is not working.")
@router.get("/preferences", response_model=UserPreferencesResponse)
@limiter.limit("30/minute")
async def get_preferences(
@@ -189,14 +164,10 @@ async def get_preferences(
):
prefs = get_user_preferences(db, current_user.id)
available_backends = ["aliyun"]
if can_user_use_local_model(current_user):
available_backends.append("local")
return {
"default_backend": prefs.get("default_backend", "aliyun"),
"default_backend": "local",
"onboarding_completed": prefs.get("onboarding_completed", False),
"available_backends": available_backends
"available_backends": ["local"]
}
@router.put("/preferences")
@@ -207,13 +178,6 @@ async def update_preferences(
current_user: Annotated[User, Depends(get_current_user)],
db: Session = Depends(get_db)
):
if preferences.default_backend == "local":
if not can_user_use_local_model(current_user):
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail="Local model is not available. Please contact administrator."
)
updated_user = update_user_preferences(
db,
current_user.id,