Skip to content

Commit

Permalink
fix: modified a private function for batch collab
Browse files Browse the repository at this point in the history
  • Loading branch information
qinluhe committed May 17, 2024
1 parent 9713270 commit 6ed420d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion libs/client-api-wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ impl ClientAPI {
tracing::debug!("batch_get_collab: {:?}", params);
let workspace_id = workspace_id.as_str();
let params: Vec<QueryCollab> = params.0.into_iter().map(|p| p.into()).collect();
match self.client.batch_get_collab(workspace_id, params).await {
match self.client.batch_post_collab(workspace_id, params).await {
Ok(data) => Ok(BatchClientEncodeCollab::from(data)),
Err(err) => Err(ClientResponse::from(err)),
}
Expand Down
27 changes: 24 additions & 3 deletions libs/client-api/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -963,20 +963,42 @@ impl Client {
AppResponse::<()>::from_response(resp).await?.into_error()
}

// The browser will call this API to get the collab list, because the URL length limit and browser can't send the body in GET request
#[instrument(level = "info", skip_all, err)]
pub async fn batch_post_collab(
&self,
workspace_id: &str,
params: Vec<QueryCollab>,
) -> Result<BatchQueryCollabResult, AppResponseError> {
self
.send_batch_collab_request(Method::POST, workspace_id, params)
.await
}

#[instrument(level = "info", skip_all, err)]
pub async fn batch_get_collab(
&self,
workspace_id: &str,
params: Vec<QueryCollab>,
) -> Result<BatchQueryCollabResult, AppResponseError> {
self
.send_batch_collab_request(Method::GET, workspace_id, params)
.await
}

async fn send_batch_collab_request(
&self,
method: Method,
workspace_id: &str,
params: Vec<QueryCollab>,
) -> Result<BatchQueryCollabResult, AppResponseError> {
let url = format!(
"{}/api/workspace/{}/collab_list",
self.base_url, workspace_id
);
let params = BatchQueryCollabParams(params);
// Use POST to avoid URL length limit
let resp = self
.http_client_with_auth(Method::POST, &url)
.http_client_with_auth(method, &url)
.await?
.json(&params)
.send()
Expand All @@ -986,7 +1008,6 @@ impl Client {
.await?
.into_data()
}

#[instrument(level = "info", skip_all, err)]
pub async fn delete_collab(&self, params: DeleteCollabParams) -> Result<(), AppResponseError> {
let url = format!(
Expand Down

0 comments on commit 6ed420d

Please sign in to comment.