use actix_web::{HttpResponse, web}; use crate::api::response::{ApiErrorResponse, ApiResponse}; use crate::error::AppError; use crate::models::users::UserAppearance; use crate::service::AppService; use crate::service::user::appearance::UpdateUserAppearanceParams; use crate::session::Session; /// Update user appearance settings /// /// Updates the authenticated user's UI appearance preferences. /// Requires authentication. /// /// Updatable fields: /// - theme: UI theme ("system", "light", "dark") /// - color_scheme: Color scheme ("system", "light", "dark") /// - density: UI density ("compact", "comfortable") /// - font_size: Font size ("small", "medium", "large") /// - editor_theme: Code editor theme name /// - markdown_preview: Enable/disable markdown live preview /// - reduced_motion: Enable/disable reduced motion /// /// All fields are optional; only provided fields are updated. /// Returns the updated appearance settings. #[utoipa::path( put, path = "/api/v1/user/appearance", tag = "User", operation_id = "userUpdateAppearance", request_body( content = UpdateUserAppearanceParams, description = "Appearance update parameters (all fields optional)", content_type = "application/json" ), responses( (status = 200, description = "Appearance settings updated successfully. Returns all updated UI preferences.", body = ApiResponse), (status = 400, description = "Invalid parameters: unsupported theme, color scheme, density, or font size", body = ApiErrorResponse), (status = 401, description = "Authentication required or session expired", body = ApiErrorResponse), (status = 500, description = "Internal server error", body = ApiErrorResponse), ), security( ("session_cookie" = []) ) )] pub async fn update_appearance( service: web::Data, session: Session, params: web::Json, ) -> Result { let appearance = service .user .user_update_appearance(&session, params.into_inner()) .await?; Ok(HttpResponse::Ok().json(ApiResponse::new(appearance))) }