Skip to content
Clone
main
32 lines 1.0 KB Rust
use api::http::{Json, State};
use ::session::AuthedUser;
use api::rest::{AppResponseData, NoData};
use crate::AuthService;
use crate::errors::ApiError;
use crate::services::profile::UpdateProfileCmd;
#[utoipa::path(
patch,
path = "/me",
tag = "account",
description = "增量更新当前用户的显示资料、时区语言、可见性和资料开关。",
request_body = UpdateProfileCmd,
responses(
(status = 200, description = "profile fields updated", body = AppResponseData<NoData>),
(status = 400, description = "request failed validation", body = AppResponseData<NoData>),
(status = 401, description = "authentication required", body = AppResponseData<NoData>)
)
)]
pub async fn update_profile(
State(service): State<AuthService>,
AuthedUser(uid): AuthedUser,
Json(cmd): Json<UpdateProfileCmd>,
) -> Result<AppResponseData<NoData>, ApiError> {
service
.update_profile(uid, cmd)
.await
.map_err(ApiError::from)?;
Ok(AppResponseData::empty())
}