refactor: update Rust API channel layer (interact, message, mod)
This commit is contained in:
parent
70818a7c71
commit
d0155c66d2
@ -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")
|
||||
|
||||
@ -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<Uuid>,
|
||||
bus: web::Data<ChannelBus>,
|
||||
) -> Result<HttpResponse, ApiError> {
|
||||
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",
|
||||
|
||||
@ -31,6 +31,7 @@ pub struct MessageListParams {
|
||||
pub struct MessageAroundParams {
|
||||
pub seq: i64,
|
||||
pub limit: Option<u64>,
|
||||
pub thread: Option<Uuid>,
|
||||
}
|
||||
|
||||
#[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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user