Skip to content

Commit

Permalink
chore: remove collab member CRUD
Browse files Browse the repository at this point in the history
  • Loading branch information
khorshuheng committed Jan 18, 2025
1 parent 6aca032 commit b3ab6da
Show file tree
Hide file tree
Showing 11 changed files with 7 additions and 760 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

103 changes: 1 addition & 102 deletions libs/client-api/src/http_member.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use crate::http::log_request_id;
use crate::Client;
use client_api_entity::{
AFCollabMember, AFCollabMembers, AFWorkspaceInvitation, AFWorkspaceInvitationStatus,
AFWorkspaceMember, InsertCollabMemberParams, QueryCollabMembers, QueryWorkspaceMember,
UpdateCollabMemberParams, WorkspaceCollabIdentify,
AFWorkspaceInvitation, AFWorkspaceInvitationStatus, AFWorkspaceMember, QueryWorkspaceMember,
};
use reqwest::Method;
use shared_entity::dto::workspace_dto::{
Expand Down Expand Up @@ -183,105 +181,6 @@ impl Client {
Ok(())
}

#[instrument(level = "info", skip_all, err)]
pub async fn add_collab_member(
&self,
params: InsertCollabMemberParams,
) -> Result<(), AppResponseError> {
let url = format!(
"{}/api/workspace/{}/collab/{}/member",
self.base_url, params.workspace_id, &params.object_id
);
let resp = self
.http_client_with_auth(Method::POST, &url)
.await?
.json(&params)
.send()
.await?;
log_request_id(&resp);
AppResponse::<()>::from_response(resp).await?.into_error()
}

#[instrument(level = "info", skip_all, err)]
pub async fn get_collab_member(
&self,
params: WorkspaceCollabIdentify,
) -> Result<AFCollabMember, AppResponseError> {
let url = format!(
"{}/api/workspace/{}/collab/{}/member",
self.base_url, params.workspace_id, &params.object_id
);
let resp = self
.http_client_with_auth(Method::GET, &url)
.await?
.json(&params)
.send()
.await?;
log_request_id(&resp);
AppResponse::<AFCollabMember>::from_response(resp)
.await?
.into_data()
}

#[instrument(level = "info", skip_all, err)]
pub async fn update_collab_member(
&self,
params: UpdateCollabMemberParams,
) -> Result<(), AppResponseError> {
let url = format!(
"{}/api/workspace/{}/collab/{}/member",
self.base_url, params.workspace_id, &params.object_id
);
let resp = self
.http_client_with_auth(Method::PUT, &url)
.await?
.json(&params)
.send()
.await?;
log_request_id(&resp);
AppResponse::<()>::from_response(resp).await?.into_error()
}

#[instrument(level = "info", skip_all, err)]
pub async fn remove_collab_member(
&self,
params: WorkspaceCollabIdentify,
) -> Result<(), AppResponseError> {
let url = format!(
"{}/api/workspace/{}/collab/{}/member",
self.base_url, params.workspace_id, &params.object_id
);
let resp = self
.http_client_with_auth(Method::DELETE, &url)
.await?
.json(&params)
.send()
.await?;
log_request_id(&resp);
AppResponse::<()>::from_response(resp).await?.into_error()
}

#[instrument(level = "info", skip_all, err)]
pub async fn get_collab_members(
&self,
params: QueryCollabMembers,
) -> Result<AFCollabMembers, AppResponseError> {
let url = format!(
"{}/api/workspace/{}/collab/{}/member/list",
self.base_url, params.workspace_id, &params.object_id
);
let resp = self
.http_client_with_auth(Method::GET, &url)
.await?
.json(&params)
.send()
.await?;
log_request_id(&resp);
AppResponse::<AFCollabMembers>::from_response(resp)
.await?
.into_data()
}

#[instrument(level = "info", skip_all, err)]
pub async fn get_workspace_member(
&self,
Expand Down
31 changes: 0 additions & 31 deletions libs/database-entity/src/dto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,27 +353,6 @@ pub struct WorkspaceUsage {
pub total_document_size: i64,
}

#[derive(Debug, Clone, Validate, Serialize, Deserialize)]
pub struct InsertCollabMemberParams {
pub uid: i64,
#[validate(custom(function = "validate_not_empty_str"))]
pub workspace_id: String,
#[validate(custom(function = "validate_not_empty_str"))]
pub object_id: String,
pub access_level: AFAccessLevel,
}

pub type UpdateCollabMemberParams = InsertCollabMemberParams;

#[derive(Debug, Clone, Validate, Serialize, Deserialize)]
pub struct WorkspaceCollabIdentify {
pub uid: i64,
#[validate(custom(function = "validate_not_empty_str"))]
pub workspace_id: String,
#[validate(custom(function = "validate_not_empty_str"))]
pub object_id: String,
}

#[derive(Serialize, Deserialize)]
pub struct UpdatePublishNamespace {
pub old_namespace: String,
Expand Down Expand Up @@ -407,13 +386,6 @@ pub struct QueryWorkspaceMember {
pub uid: i64,
}

#[derive(Serialize, Deserialize)]
pub struct AFCollabMember {
pub uid: i64,
pub oid: String,
pub permission: AFPermission,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct AFCollabEmbedInfo {
pub object_id: String,
Expand Down Expand Up @@ -609,9 +581,6 @@ impl Ord for AFAccessLevel {
}
}

#[derive(Serialize, Deserialize)]
pub struct AFCollabMembers(pub Vec<AFCollabMember>);

pub type RawData = Vec<u8>;

#[derive(Serialize, Deserialize)]
Expand Down
Loading

0 comments on commit b3ab6da

Please sign in to comment.