use ::session::AuthedUser; use api::http::{Json, Path, State}; use api::rest::{AppResponseData, NoData}; use uuid::Uuid; use crate::errors::ApiError; use crate::services::service::ChatService; use crate::services::settings::{RoomSettingDto, UpdateRoomSettingCmd}; #[utoipa::path( get, path = "/chat/rooms/{room_id}/settings", tag = "chat", description = "读取当前用户针对单个房间的通知与显示设置。", params(("room_id" = Uuid, Path, description = "room id")), responses( (status = 200, description = "room setting", body = AppResponseData), (status = 404, description = "not found", body = AppResponseData), (status = 401, description = "authentication required", body = AppResponseData) ) )] pub async fn get_room_setting( State(service): State, AuthedUser(uid): AuthedUser, Path(room_id): Path, ) -> Result, ApiError> { let dto = service.get_room_setting(uid, room_id).await?; Ok(AppResponseData::ok(dto)) } #[utoipa::path( put, path = "/chat/rooms/{room_id}/settings", tag = "chat", description = "更新当前用户的房间通知级别、收藏、隐藏或免打扰设置。", params(("room_id" = Uuid, Path, description = "room id")), request_body = UpdateRoomSettingCmd, responses( (status = 200, description = "room setting updated", body = AppResponseData), (status = 404, description = "not found", body = AppResponseData), (status = 400, description = "request failed validation", body = AppResponseData), (status = 401, description = "authentication required", body = AppResponseData) ) )] pub async fn update_room_setting( State(service): State, AuthedUser(uid): AuthedUser, Path(room_id): Path, Json(cmd): Json, ) -> Result, ApiError> { let dto = service.update_room_setting(uid, room_id, cmd).await?; Ok(AppResponseData::ok(dto)) }