From d0155c66d2e42e80c4cc972392d916cf91835efe Mon Sep 17 00:00:00 2001 From: zhenyi <434836402@qq.com> Date: Sat, 30 May 2026 15:07:03 +0800 Subject: [PATCH] refactor: update Rust API channel layer (interact, message, mod) --- lib/api/src/channel/mod.rs | 3 ++- lib/api/src/channel/rest_interact.rs | 21 +++++++++++++++++++++ lib/api/src/channel/rest_message.rs | 2 ++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/api/src/channel/mod.rs b/lib/api/src/channel/mod.rs index fb14f87..47b70e6 100644 --- a/lib/api/src/channel/mod.rs +++ b/lib/api/src/channel/mod.rs @@ -88,7 +88,8 @@ pub fn configure(cfg: &mut ServiceConfig, bus: ChannelBus) { ) .service( actix_web::web::resource("/rooms/{room_id}/threads") - .route(actix_web::web::post().to(rest_interact::thread_create)), + .route(actix_web::web::post().to(rest_interact::thread_create)) + .route(actix_web::web::get().to(rest_interact::thread_list)), ) .service( actix_web::web::resource("/threads/{thread_id}/resolve") diff --git a/lib/api/src/channel/rest_interact.rs b/lib/api/src/channel/rest_interact.rs index e160431..a639a05 100644 --- a/lib/api/src/channel/rest_interact.rs +++ b/lib/api/src/channel/rest_interact.rs @@ -103,6 +103,27 @@ pub async fn thread_create( Ok(created_json(result)) } +#[utoipa::path( + get, + path = "/api/v1/ws/rooms/{room_id}/threads", + responses((status = 200, description = "Thread list")), + tag = "channel", +)] +pub async fn thread_list( + req: HttpRequest, + room_id: web::Path, + bus: web::Data, +) -> Result { + let user_id = extract_user(&req)?; + let msg = WsInMessage::ThreadList { + room: room_id.into_inner(), + }; + let result = WsHandler::handle(&bus, user_id, msg) + .await + .map_err(channel_err)?; + Ok(ok_json(result)) +} + #[utoipa::path( patch, path = "/api/v1/ws/threads/{thread_id}/resolve", diff --git a/lib/api/src/channel/rest_message.rs b/lib/api/src/channel/rest_message.rs index 516ac60..19dc5e0 100644 --- a/lib/api/src/channel/rest_message.rs +++ b/lib/api/src/channel/rest_message.rs @@ -31,6 +31,7 @@ pub struct MessageListParams { pub struct MessageAroundParams { pub seq: i64, pub limit: Option, + pub thread: Option, } #[derive(Debug, Deserialize, utoipa::IntoParams)] @@ -163,6 +164,7 @@ pub async fn messages_around( room: room_id.into_inner(), seq: params.seq, limit: params.limit, + thread: params.thread, }; let result = WsHandler::handle(&bus, user_id, msg) .await