Skip to content
Clone
main
26 lines 996 B Rust
use ::session::AuthedUser;
use api::http::State;
use api::rest::{AppResponseData, NoData};
use crate::AuthService;
use crate::errors::ApiError;
use crate::services::preferences::UserPreferencesDto;
#[utoipa::path(
get,
path = "/me/preferences",
tag = "account",
description = "读取当前用户的通知与界面偏好,未配置时返回默认值。",
responses(
(status = 200, description = "preferences for the current user, defaults when unset", body = AppResponseData<UserPreferencesDto>),
(status = 404, description = "resource not found", body = AppResponseData<NoData>),
(status = 401, description = "authentication required", body = AppResponseData<NoData>)
)
)]
pub async fn get_preferences(
State(service): State<AuthService>,
AuthedUser(uid): AuthedUser,
) -> Result<AppResponseData<UserPreferencesDto>, ApiError> {
let resp = service.preferences(uid).await.map_err(ApiError::from)?;
Ok(AppResponseData::ok(resp))
}