chore: use http query instead of json for batch get collab

This commit is contained in:
Zack Fu Zi Xiang 2024-05-08 16:29:27 +08:00
parent 359433f14c
commit e87e88446c
No known key found for this signature in database
2 changed files with 28 additions and 4 deletions

View File

@ -970,14 +970,14 @@ impl Client {
params: Vec<QueryCollab>,
) -> Result<BatchQueryCollabResult, AppResponseError> {
let url = format!(
"{}/api/workspace/{}/collab_list",
"{}/api/workspace/v1/{}/collab_list",
self.base_url, workspace_id
);
let params = BatchQueryCollabParams(params);
let resp = self
.http_client_with_auth(Method::GET, &url)
.await?
.json(&params)
.query(&params)
.send()
.await?;
log_request_id(&resp);

View File

@ -7,7 +7,7 @@ use crate::biz::user::auth::jwt::UserUuid;
use crate::biz::workspace;
use crate::domain::compression::{decompress, CompressionType, X_COMPRESSION_TYPE};
use crate::state::AppState;
use actix_web::web::{Bytes, Payload};
use actix_web::web::{Bytes, Payload, Query};
use actix_web::web::{Data, Json, PayloadConfig};
use actix_web::{web, Scope};
use actix_web::{HttpRequest, Result};
@ -126,9 +126,12 @@ pub fn workspace_scope() -> Scope {
web::resource("/{workspace_id}/collab/{object_id}/member/list")
.route(web::get().to(get_collab_member_list_handler)),
)
.service(
.service( // Deprecated
web::resource("/{workspace_id}/collab_list").route(web::get().to(batch_get_collab_handler)),
)
.service(
web::resource("/v1/{workspace_id}/collab_list").route(web::get().to(v1_batch_get_collab_handler)),
)
.service(
web::resource("/{workspace_id}/summarize_row").route(web::post().to(summary_row_handler)),
)
@ -746,6 +749,7 @@ async fn get_all_collab_snapshot_list_handler(
Ok(Json(AppResponse::Ok().with_data(data)))
}
// Deprecated
#[instrument(level = "debug", skip(payload, state), err)]
async fn batch_get_collab_handler(
user_uuid: UserUuid,
@ -766,6 +770,26 @@ async fn batch_get_collab_handler(
Ok(Json(AppResponse::Ok().with_data(result)))
}
#[instrument(level = "debug", skip(payload, state), err)]
async fn v1_batch_get_collab_handler(
user_uuid: UserUuid,
state: Data<AppState>,
payload: Query<BatchQueryCollabParams>,
) -> Result<Json<AppResponse<BatchQueryCollabResult>>> {
let uid = state
.user_cache
.get_user_uid(&user_uuid)
.await
.map_err(AppResponseError::from)?;
let result = BatchQueryCollabResult(
state
.collab_access_control_storage
.batch_get_collab(&uid, payload.into_inner().0)
.await,
);
Ok(Json(AppResponse::Ok().with_data(result)))
}
#[instrument(skip(state, payload), err)]
async fn update_collab_handler(
user_uuid: UserUuid,