From d7e70e0c7cd89d502b29337f2c9336677ee9af7b Mon Sep 17 00:00:00 2001 From: Zack Fu Zi Xiang Date: Mon, 24 Jun 2024 00:13:20 +0800 Subject: [PATCH] chore: remove deprecated add member directly --- frontend/rust-lib/Cargo.toml | 2 +- .../src/folder_event.rs | 37 +-- .../tests/user/af_cloud_test/member_test.rs | 6 +- .../user/af_cloud_test/workspace_test.rs | 2 +- .../af_cloud/impls/user/cloud_service_impl.rs | 25 +- frontend/rust-lib/flowy-sqlite/src/schema.rs | 18 +- frontend/rust-lib/flowy-user-pub/src/cloud.rs | 9 - .../flowy-user/src/entities/workspace.rs | 1 + .../rust-lib/flowy-user/src/event_handler.rs | 13 - frontend/rust-lib/flowy-user/src/event_map.rs | 4 +- .../user_manager/manager_user_workspace.rs | 14 - pace_id: String, | 255 ++++++++++++++++++ truct AddWorkspaceMemberPB { | 255 ++++++++++++++++++ 13 files changed, 548 insertions(+), 93 deletions(-) create mode 100644 pace_id: String, create mode 100644 truct AddWorkspaceMemberPB { diff --git a/frontend/rust-lib/Cargo.toml b/frontend/rust-lib/Cargo.toml index 27342183192fb..590bf9fb736c5 100644 --- a/frontend/rust-lib/Cargo.toml +++ b/frontend/rust-lib/Cargo.toml @@ -94,7 +94,7 @@ validator = { version = "0.16.1", features = ["derive"] } # Please using the following command to update the revision id # Current directory: frontend -# Run the script.add_workspace_members: +# Run the script: # scripts/tool/update_client_api_rev.sh new_rev_id # ⚠️⚠️⚠️️ client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "6262816043efeede8823d7a7ea252083adf407e9" } diff --git a/frontend/rust-lib/event-integration-test/src/folder_event.rs b/frontend/rust-lib/event-integration-test/src/folder_event.rs index af4de3f5d0826..359f9188cb5d6 100644 --- a/frontend/rust-lib/event-integration-test/src/folder_event.rs +++ b/frontend/rust-lib/event-integration-test/src/folder_event.rs @@ -7,7 +7,7 @@ use flowy_folder::event_map::FolderEvent::*; use flowy_folder::{entities::*, ViewLayout}; use flowy_search::services::manager::{SearchHandler, SearchType}; use flowy_user::entities::{ - AcceptWorkspaceInvitationPB, AddWorkspaceMemberPB, QueryWorkspacePB, RemoveWorkspaceMemberPB, + AcceptWorkspaceInvitationPB, QueryWorkspacePB, RemoveWorkspaceMemberPB, RepeatedWorkspaceInvitationPB, RepeatedWorkspaceMemberPB, WorkspaceMemberInvitationPB, WorkspaceMemberPB, }; @@ -19,21 +19,6 @@ use crate::event_builder::EventBuilder; use crate::EventIntegrationTest; impl EventIntegrationTest { - pub async fn add_workspace_member(&self, workspace_id: &str, email: &str) { - if let Some(err) = EventBuilder::new(self.clone()) - .event(UserEvent::AddWorkspaceMember) - .payload(AddWorkspaceMemberPB { - workspace_id: workspace_id.to_string(), - email: email.to_string(), - }) - .async_send() - .await - .error() - { - panic!("Add workspace member failed: {:?}", err); - } - } - pub async fn invite_workspace_member(&self, workspace_id: &str, email: &str, role: Role) { EventBuilder::new(self.clone()) .event(UserEvent::InviteWorkspaceMember) @@ -46,6 +31,26 @@ impl EventIntegrationTest { .await; } + // convenient function to add workspace member by inviting and accepting the invitation + pub async fn add_workspace_member(&self, workspace_id: &str, other: &EventIntegrationTest) { + let other_email = other.get_user_profile().await.unwrap().email; + + self + .invite_workspace_member(workspace_id, &other_email, Role::Member) + .await; + + let invitations = other.list_workspace_invitations().await; + let target_invi = invitations + .items + .into_iter() + .find(|i| i.workspace_id == workspace_id) + .unwrap(); + + other + .accept_workspace_invitation(&target_invi.invite_id) + .await; + } + pub async fn list_workspace_invitations(&self) -> RepeatedWorkspaceInvitationPB { EventBuilder::new(self.clone()) .event(UserEvent::ListWorkspaceInvitations) diff --git a/frontend/rust-lib/event-integration-test/tests/user/af_cloud_test/member_test.rs b/frontend/rust-lib/event-integration-test/tests/user/af_cloud_test/member_test.rs index c5fc2479bb19f..9eba50b404a57 100644 --- a/frontend/rust-lib/event-integration-test/tests/user/af_cloud_test/member_test.rs +++ b/frontend/rust-lib/event-integration-test/tests/user/af_cloud_test/member_test.rs @@ -47,7 +47,7 @@ async fn af_cloud_add_workspace_member_test() { assert_eq!(members[0].email, user_1.email); test_1 - .add_workspace_member(&user_1.workspace_id, &user_2.email) + .add_workspace_member(&user_1.workspace_id, &test_2) .await; let members = test_1.get_workspace_members(&user_1.workspace_id).await; @@ -66,7 +66,7 @@ async fn af_cloud_delete_workspace_member_test() { let user_2 = test_2.af_cloud_sign_up().await; test_1 - .add_workspace_member(&user_1.workspace_id, &user_2.email) + .add_workspace_member(&user_1.workspace_id, &test_2) .await; test_1 @@ -88,7 +88,7 @@ async fn af_cloud_leave_workspace_test() { let user_2 = test_2.af_cloud_sign_up().await; test_1 - .add_workspace_member(&user_1.workspace_id, &user_2.email) + .add_workspace_member(&user_1.workspace_id, &test_2) .await; // test_2 should have 2 workspace diff --git a/frontend/rust-lib/event-integration-test/tests/user/af_cloud_test/workspace_test.rs b/frontend/rust-lib/event-integration-test/tests/user/af_cloud_test/workspace_test.rs index af743e7cedcb8..b72ceba33f608 100644 --- a/frontend/rust-lib/event-integration-test/tests/user/af_cloud_test/workspace_test.rs +++ b/frontend/rust-lib/event-integration-test/tests/user/af_cloud_test/workspace_test.rs @@ -182,7 +182,7 @@ async fn af_cloud_different_open_same_workspace_test() { } client_1 - .add_workspace_member(&owner_profile.workspace_id, &client_profile.email) + .add_workspace_member(&owner_profile.workspace_id, &client) .await; clients.push((client, client_profile)); } diff --git a/frontend/rust-lib/flowy-server/src/af_cloud/impls/user/cloud_service_impl.rs b/frontend/rust-lib/flowy-server/src/af_cloud/impls/user/cloud_service_impl.rs index a7928a97472a7..cbb006ce8c85b 100644 --- a/frontend/rust-lib/flowy-server/src/af_cloud/impls/user/cloud_service_impl.rs +++ b/frontend/rust-lib/flowy-server/src/af_cloud/impls/user/cloud_service_impl.rs @@ -6,8 +6,7 @@ use client_api::entity::billing_dto::{ SubscriptionPlan, SubscriptionStatus, WorkspaceSubscriptionPlan, WorkspaceSubscriptionStatus, }; use client_api::entity::workspace_dto::{ - CreateWorkspaceMember, CreateWorkspaceParam, PatchWorkspaceParam, WorkspaceMemberChangeset, - WorkspaceMemberInvitation, + CreateWorkspaceParam, PatchWorkspaceParam, WorkspaceMemberChangeset, WorkspaceMemberInvitation, }; use client_api::entity::{ AFRole, AFWorkspace, AFWorkspaceInvitation, AuthProvider, CollabParams, CreateCollabParams, @@ -222,28 +221,6 @@ where }) } - #[allow(deprecated)] - fn add_workspace_member( - &self, - user_email: String, - workspace_id: String, - ) -> FutureResult<(), FlowyError> { - let try_get_client = self.server.try_get_client(); - FutureResult::new(async move { - // TODO(zack): add_workspace_members will be deprecated after finishing the invite logic. Don't forget to remove the #[allow(deprecated)] - try_get_client? - .add_workspace_members( - workspace_id, - vec![CreateWorkspaceMember { - email: user_email, - role: AFRole::Member, - }], - ) - .await?; - Ok(()) - }) - } - fn invite_workspace_member( &self, invitee_email: String, diff --git a/frontend/rust-lib/flowy-sqlite/src/schema.rs b/frontend/rust-lib/flowy-sqlite/src/schema.rs index 49fcc254d1319..f23eb029ea544 100644 --- a/frontend/rust-lib/flowy-sqlite/src/schema.rs +++ b/frontend/rust-lib/flowy-sqlite/src/schema.rs @@ -102,13 +102,13 @@ diesel::table! { } diesel::allow_tables_to_appear_in_same_query!( - chat_message_table, - chat_table, - collab_snapshot, - upload_file_part, - upload_file_table, - user_data_migration_records, - user_table, - user_workspace_table, - workspace_members_table, + chat_message_table, + chat_table, + collab_snapshot, + upload_file_part, + upload_file_table, + user_data_migration_records, + user_table, + user_workspace_table, + workspace_members_table, ); diff --git a/frontend/rust-lib/flowy-user-pub/src/cloud.rs b/frontend/rust-lib/flowy-user-pub/src/cloud.rs index a97f7b28e1a44..0508e5c40eec2 100644 --- a/frontend/rust-lib/flowy-user-pub/src/cloud.rs +++ b/frontend/rust-lib/flowy-user-pub/src/cloud.rs @@ -178,15 +178,6 @@ pub trait UserCloudService: Send + Sync + 'static { /// Deletes a workspace owned by the user. fn delete_workspace(&self, workspace_id: &str) -> FutureResult<(), FlowyError>; - // Deprecated, use invite instead - fn add_workspace_member( - &self, - user_email: String, - workspace_id: String, - ) -> FutureResult<(), FlowyError> { - FutureResult::new(async { Ok(()) }) - } - fn invite_workspace_member( &self, invitee_email: String, diff --git a/frontend/rust-lib/flowy-user/src/entities/workspace.rs b/frontend/rust-lib/flowy-user/src/entities/workspace.rs index d860385de05a4..96660bdea26d2 100644 --- a/frontend/rust-lib/flowy-user/src/entities/workspace.rs +++ b/frontend/rust-lib/flowy-user/src/entities/workspace.rs @@ -98,6 +98,7 @@ pub struct AcceptWorkspaceInvitationPB { pub invite_id: String, } +// Deprecated #[derive(ProtoBuf, Default, Clone, Validate)] pub struct AddWorkspaceMemberPB { #[pb(index = 1)] diff --git a/frontend/rust-lib/flowy-user/src/event_handler.rs b/frontend/rust-lib/flowy-user/src/event_handler.rs index b2c36d8c6b604..831289d1b9228 100644 --- a/frontend/rust-lib/flowy-user/src/event_handler.rs +++ b/frontend/rust-lib/flowy-user/src/event_handler.rs @@ -623,19 +623,6 @@ pub async fn update_reminder_event_handler( Ok(()) } -#[tracing::instrument(level = "debug", skip_all, err)] -pub async fn add_workspace_member_handler( - data: AFPluginData, - manager: AFPluginState>, -) -> Result<(), FlowyError> { - let data = data.try_into_inner()?; - let manager = upgrade_manager(manager)?; - manager - .add_workspace_member(data.email, data.workspace_id) - .await?; - Ok(()) -} - #[tracing::instrument(level = "debug", skip_all, err)] pub async fn delete_workspace_member_handler( data: AFPluginData, diff --git a/frontend/rust-lib/flowy-user/src/event_map.rs b/frontend/rust-lib/flowy-user/src/event_map.rs index 42be2a256b388..387f1deaa26ba 100644 --- a/frontend/rust-lib/flowy-user/src/event_map.rs +++ b/frontend/rust-lib/flowy-user/src/event_map.rs @@ -54,9 +54,6 @@ pub fn init(user_manager: Weak) -> AFPlugin { .event(UserEvent::SetNotificationSettings, set_notification_settings) .event(UserEvent::GetNotificationSettings, get_notification_settings) .event(UserEvent::ImportAppFlowyDataFolder, import_appflowy_data_folder_handler) - // Workspace member - .event(UserEvent::AddWorkspaceMember, add_workspace_member_handler) // deprecated, use invite - // instead .event(UserEvent::GetMemberInfo, get_workspace_member_info) .event(UserEvent::RemoveWorkspaceMember, delete_workspace_member_handler) .event(UserEvent::GetWorkspaceMembers, get_workspace_members_handler) @@ -196,6 +193,7 @@ pub enum UserEvent { #[event(output = "NotificationSettingsPB")] GetNotificationSettings = 36, + // Deprecated #[event(input = "AddWorkspaceMemberPB")] AddWorkspaceMember = 37, diff --git a/frontend/rust-lib/flowy-user/src/user_manager/manager_user_workspace.rs b/frontend/rust-lib/flowy-user/src/user_manager/manager_user_workspace.rs index cee00fecd40bc..0c22d28d434f5 100644 --- a/frontend/rust-lib/flowy-user/src/user_manager/manager_user_workspace.rs +++ b/frontend/rust-lib/flowy-user/src/user_manager/manager_user_workspace.rs @@ -327,20 +327,6 @@ impl UserManager { Ok(()) } - // deprecated, use invite instead - pub async fn add_workspace_member( - &self, - user_email: String, - workspace_id: String, - ) -> FlowyResult<()> { - self - .cloud_services - .get_user_service()? - .add_workspace_member(user_email, workspace_id) - .await?; - Ok(()) - } - pub async fn remove_workspace_member( &self, user_email: String, diff --git a/pace_id: String, b/pace_id: String, new file mode 100644 index 0000000000000..e2ac641130b91 --- /dev/null +++ b/pace_id: String, @@ -0,0 +1,255 @@ +diff --git a/frontend/rust-lib/Cargo.toml b/frontend/rust-lib/Cargo.toml +index 273421831..590bf9fb7 100644 +--- a/frontend/rust-lib/Cargo.toml ++++ b/frontend/rust-lib/Cargo.toml +@@ -94,7 +94,7 @@ validator = { version = "0.16.1", features = ["derive"] } +  + # Please using the following command to update the revision id + # Current directory: frontend +-# Run the script.add_workspace_members: ++# Run the script: + # scripts/tool/update_client_api_rev.sh new_rev_id + # ⚠️⚠️⚠️️ + client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "6262816043efeede8823d7a7ea252083adf407e9" } +diff --git a/frontend/rust-lib/event-integration-test/src/folder_event.rs b/frontend/rust-lib/event-integration-test/src/folder_event.rs +index af4de3f5d..359f9188c 100644 +--- a/frontend/rust-lib/event-integration-test/src/folder_event.rs ++++ b/frontend/rust-lib/event-integration-test/src/folder_event.rs +@@ -7,7 +7,7 @@ use flowy_folder::event_map::FolderEvent::*; + use flowy_folder::{entities::*, ViewLayout}; + use flowy_search::services::manager::{SearchHandler, SearchType}; + use flowy_user::entities::{ +- AcceptWorkspaceInvitationPB, AddWorkspaceMemberPB, QueryWorkspacePB, RemoveWorkspaceMemberPB, ++ AcceptWorkspaceInvitationPB, QueryWorkspacePB, RemoveWorkspaceMemberPB, + RepeatedWorkspaceInvitationPB, RepeatedWorkspaceMemberPB, WorkspaceMemberInvitationPB, + WorkspaceMemberPB, + }; +@@ -19,21 +19,6 @@ use crate::event_builder::EventBuilder; + use crate::EventIntegrationTest; +  + impl EventIntegrationTest { +- pub async fn add_workspace_member(&self, workspace_id: &str, email: &str) { +- if let Some(err) = EventBuilder::new(self.clone()) +- .event(UserEvent::AddWorkspaceMember) +- .payload(AddWorkspaceMemberPB { +- workspace_id: workspace_id.to_string(), +- email: email.to_string(), +- }) +- .async_send() +- .await +- .error() +- { +- panic!("Add workspace member failed: {:?}", err); +- } +- } +- + pub async fn invite_workspace_member(&self, workspace_id: &str, email: &str, role: Role) { + EventBuilder::new(self.clone()) + .event(UserEvent::InviteWorkspaceMember) +@@ -46,6 +31,26 @@ impl EventIntegrationTest { + .await; + } +  ++ // convenient function to add workspace member by inviting and accepting the invitation ++ pub async fn add_workspace_member(&self, workspace_id: &str, other: &EventIntegrationTest) { ++ let other_email = other.get_user_profile().await.unwrap().email; ++ ++ self ++ .invite_workspace_member(workspace_id, &other_email, Role::Member) ++ .await; ++ ++ let invitations = other.list_workspace_invitations().await; ++ let target_invi = invitations ++ .items ++ .into_iter() ++ .find(|i| i.workspace_id == workspace_id) ++ .unwrap(); ++ ++ other ++ .accept_workspace_invitation(&target_invi.invite_id) ++ .await; ++ } ++ + pub async fn list_workspace_invitations(&self) -> RepeatedWorkspaceInvitationPB { + EventBuilder::new(self.clone()) + .event(UserEvent::ListWorkspaceInvitations) +diff --git a/frontend/rust-lib/event-integration-test/tests/user/af_cloud_test/member_test.rs b/frontend/rust-lib/event-integration-test/tests/user/af_cloud_test/member_test.rs +index c5fc2479b..9eba50b40 100644 +--- a/frontend/rust-lib/event-integration-test/tests/user/af_cloud_test/member_test.rs ++++ b/frontend/rust-lib/event-integration-test/tests/user/af_cloud_test/member_test.rs +@@ -47,7 +47,7 @@ async fn af_cloud_add_workspace_member_test() { + assert_eq!(members[0].email, user_1.email); +  + test_1 +- .add_workspace_member(&user_1.workspace_id, &user_2.email) ++ .add_workspace_member(&user_1.workspace_id, &test_2) + .await; +  + let members = test_1.get_workspace_members(&user_1.workspace_id).await; +@@ -66,7 +66,7 @@ async fn af_cloud_delete_workspace_member_test() { + let user_2 = test_2.af_cloud_sign_up().await; +  + test_1 +- .add_workspace_member(&user_1.workspace_id, &user_2.email) ++ .add_workspace_member(&user_1.workspace_id, &test_2) + .await; +  + test_1 +@@ -88,7 +88,7 @@ async fn af_cloud_leave_workspace_test() { + let user_2 = test_2.af_cloud_sign_up().await; +  + test_1 +- .add_workspace_member(&user_1.workspace_id, &user_2.email) ++ .add_workspace_member(&user_1.workspace_id, &test_2) + .await; +  + // test_2 should have 2 workspace +diff --git a/frontend/rust-lib/event-integration-test/tests/user/af_cloud_test/workspace_test.rs b/frontend/rust-lib/event-integration-test/tests/user/af_cloud_test/workspace_test.rs +index af743e7ce..b72ceba33 100644 +--- a/frontend/rust-lib/event-integration-test/tests/user/af_cloud_test/workspace_test.rs ++++ b/frontend/rust-lib/event-integration-test/tests/user/af_cloud_test/workspace_test.rs +@@ -182,7 +182,7 @@ async fn af_cloud_different_open_same_workspace_test() { + } +  + client_1 +- .add_workspace_member(&owner_profile.workspace_id, &client_profile.email) ++ .add_workspace_member(&owner_profile.workspace_id, &client) + .await; + clients.push((client, client_profile)); + } +diff --git a/frontend/rust-lib/flowy-server/src/af_cloud/impls/user/cloud_service_impl.rs b/frontend/rust-lib/flowy-server/src/af_cloud/impls/user/cloud_service_impl.rs +index a7928a974..cbb006ce8 100644 +--- a/frontend/rust-lib/flowy-server/src/af_cloud/impls/user/cloud_service_impl.rs ++++ b/frontend/rust-lib/flowy-server/src/af_cloud/impls/user/cloud_service_impl.rs +@@ -6,8 +6,7 @@ use client_api::entity::billing_dto::{ + SubscriptionPlan, SubscriptionStatus, WorkspaceSubscriptionPlan, WorkspaceSubscriptionStatus, + }; + use client_api::entity::workspace_dto::{ +- CreateWorkspaceMember, CreateWorkspaceParam, PatchWorkspaceParam, WorkspaceMemberChangeset, +- WorkspaceMemberInvitation, ++ CreateWorkspaceParam, PatchWorkspaceParam, WorkspaceMemberChangeset, WorkspaceMemberInvitation, + }; + use client_api::entity::{ + AFRole, AFWorkspace, AFWorkspaceInvitation, AuthProvider, CollabParams, CreateCollabParams, +@@ -222,28 +221,6 @@ where + }) + } +  +- #[allow(deprecated)] +- fn add_workspace_member( +- &self, +- user_email: String, +- workspace_id: String, +- ) -> FutureResult<(), FlowyError> { +- let try_get_client = self.server.try_get_client(); +- FutureResult::new(async move { +- // TODO(zack): add_workspace_members will be deprecated after finishing the invite logic. Don't forget to remove the #[allow(deprecated)] +- try_get_client? +- .add_workspace_members( +- workspace_id, +- vec![CreateWorkspaceMember { +- email: user_email, +- role: AFRole::Member, +- }], +- ) +- .await?; +- Ok(()) +- }) +- } +- + fn invite_workspace_member( + &self, + invitee_email: String, +diff --git a/frontend/rust-lib/flowy-user-pub/src/cloud.rs b/frontend/rust-lib/flowy-user-pub/src/cloud.rs +index a97f7b28e..0508e5c40 100644 +--- a/frontend/rust-lib/flowy-user-pub/src/cloud.rs ++++ b/frontend/rust-lib/flowy-user-pub/src/cloud.rs +@@ -178,15 +178,6 @@ pub trait UserCloudService: Send + Sync + 'static { + /// Deletes a workspace owned by the user. + fn delete_workspace(&self, workspace_id: &str) -> FutureResult<(), FlowyError>; +  +- // Deprecated, use invite instead +- fn add_workspace_member( +- &self, +- user_email: String, +- workspace_id: String, +- ) -> FutureResult<(), FlowyError> { +- FutureResult::new(async { Ok(()) }) +- } +- + fn invite_workspace_member( + &self, + invitee_email: String, +diff --git a/frontend/rust-lib/flowy-user/src/event_handler.rs b/frontend/rust-lib/flowy-user/src/event_handler.rs +index b2c36d8c6..831289d1b 100644 +--- a/frontend/rust-lib/flowy-user/src/event_handler.rs ++++ b/frontend/rust-lib/flowy-user/src/event_handler.rs +@@ -623,19 +623,6 @@ pub async fn update_reminder_event_handler( + Ok(()) + } +  +-#[tracing::instrument(level = "debug", skip_all, err)] +-pub async fn add_workspace_member_handler( +- data: AFPluginData, +- manager: AFPluginState>, +-) -> Result<(), FlowyError> { +- let data = data.try_into_inner()?; +- let manager = upgrade_manager(manager)?; +- manager +- .add_workspace_member(data.email, data.workspace_id) +- .await?; +- Ok(()) +-} +- + #[tracing::instrument(level = "debug", skip_all, err)] + pub async fn delete_workspace_member_handler( + data: AFPluginData, +diff --git a/frontend/rust-lib/flowy-user/src/event_map.rs b/frontend/rust-lib/flowy-user/src/event_map.rs +index 42be2a256..7c7db18bc 100644 +--- a/frontend/rust-lib/flowy-user/src/event_map.rs ++++ b/frontend/rust-lib/flowy-user/src/event_map.rs +@@ -54,9 +54,6 @@ pub fn init(user_manager: Weak) -> AFPlugin { + .event(UserEvent::SetNotificationSettings, set_notification_settings) + .event(UserEvent::GetNotificationSettings, get_notification_settings) + .event(UserEvent::ImportAppFlowyDataFolder, import_appflowy_data_folder_handler) +- // Workspace member +- .event(UserEvent::AddWorkspaceMember, add_workspace_member_handler) // deprecated, use invite +- // instead + .event(UserEvent::GetMemberInfo, get_workspace_member_info) + .event(UserEvent::RemoveWorkspaceMember, delete_workspace_member_handler) + .event(UserEvent::GetWorkspaceMembers, get_workspace_members_handler) +@@ -196,9 +193,6 @@ pub enum UserEvent { + #[event(output = "NotificationSettingsPB")] + GetNotificationSettings = 36, +  +- #[event(input = "AddWorkspaceMemberPB")] +- AddWorkspaceMember = 37, +- + #[event(input = "RemoveWorkspaceMemberPB")] + RemoveWorkspaceMember = 38, +  +diff --git a/frontend/rust-lib/flowy-user/src/user_manager/manager_user_workspace.rs b/frontend/rust-lib/flowy-user/src/user_manager/manager_user_workspace.rs +index cee00fecd..0c22d28d4 100644 +--- a/frontend/rust-lib/flowy-user/src/user_manager/manager_user_workspace.rs ++++ b/frontend/rust-lib/flowy-user/src/user_manager/manager_user_workspace.rs +@@ -327,20 +327,6 @@ impl UserManager { + Ok(()) + } +  +- // deprecated, use invite instead +- pub async fn add_workspace_member( +- &self, +- user_email: String, +- workspace_id: String, +- ) -> FlowyResult<()> { +- self +- .cloud_services +- .get_user_service()? +- .add_workspace_member(user_email, workspace_id) +- .await?; +- Ok(()) +- } +- + pub async fn remove_workspace_member( + &self, + user_email: String, diff --git a/truct AddWorkspaceMemberPB { b/truct AddWorkspaceMemberPB { new file mode 100644 index 0000000000000..e2ac641130b91 --- /dev/null +++ b/truct AddWorkspaceMemberPB { @@ -0,0 +1,255 @@ +diff --git a/frontend/rust-lib/Cargo.toml b/frontend/rust-lib/Cargo.toml +index 273421831..590bf9fb7 100644 +--- a/frontend/rust-lib/Cargo.toml ++++ b/frontend/rust-lib/Cargo.toml +@@ -94,7 +94,7 @@ validator = { version = "0.16.1", features = ["derive"] } +  + # Please using the following command to update the revision id + # Current directory: frontend +-# Run the script.add_workspace_members: ++# Run the script: + # scripts/tool/update_client_api_rev.sh new_rev_id + # ⚠️⚠️⚠️️ + client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "6262816043efeede8823d7a7ea252083adf407e9" } +diff --git a/frontend/rust-lib/event-integration-test/src/folder_event.rs b/frontend/rust-lib/event-integration-test/src/folder_event.rs +index af4de3f5d..359f9188c 100644 +--- a/frontend/rust-lib/event-integration-test/src/folder_event.rs ++++ b/frontend/rust-lib/event-integration-test/src/folder_event.rs +@@ -7,7 +7,7 @@ use flowy_folder::event_map::FolderEvent::*; + use flowy_folder::{entities::*, ViewLayout}; + use flowy_search::services::manager::{SearchHandler, SearchType}; + use flowy_user::entities::{ +- AcceptWorkspaceInvitationPB, AddWorkspaceMemberPB, QueryWorkspacePB, RemoveWorkspaceMemberPB, ++ AcceptWorkspaceInvitationPB, QueryWorkspacePB, RemoveWorkspaceMemberPB, + RepeatedWorkspaceInvitationPB, RepeatedWorkspaceMemberPB, WorkspaceMemberInvitationPB, + WorkspaceMemberPB, + }; +@@ -19,21 +19,6 @@ use crate::event_builder::EventBuilder; + use crate::EventIntegrationTest; +  + impl EventIntegrationTest { +- pub async fn add_workspace_member(&self, workspace_id: &str, email: &str) { +- if let Some(err) = EventBuilder::new(self.clone()) +- .event(UserEvent::AddWorkspaceMember) +- .payload(AddWorkspaceMemberPB { +- workspace_id: workspace_id.to_string(), +- email: email.to_string(), +- }) +- .async_send() +- .await +- .error() +- { +- panic!("Add workspace member failed: {:?}", err); +- } +- } +- + pub async fn invite_workspace_member(&self, workspace_id: &str, email: &str, role: Role) { + EventBuilder::new(self.clone()) + .event(UserEvent::InviteWorkspaceMember) +@@ -46,6 +31,26 @@ impl EventIntegrationTest { + .await; + } +  ++ // convenient function to add workspace member by inviting and accepting the invitation ++ pub async fn add_workspace_member(&self, workspace_id: &str, other: &EventIntegrationTest) { ++ let other_email = other.get_user_profile().await.unwrap().email; ++ ++ self ++ .invite_workspace_member(workspace_id, &other_email, Role::Member) ++ .await; ++ ++ let invitations = other.list_workspace_invitations().await; ++ let target_invi = invitations ++ .items ++ .into_iter() ++ .find(|i| i.workspace_id == workspace_id) ++ .unwrap(); ++ ++ other ++ .accept_workspace_invitation(&target_invi.invite_id) ++ .await; ++ } ++ + pub async fn list_workspace_invitations(&self) -> RepeatedWorkspaceInvitationPB { + EventBuilder::new(self.clone()) + .event(UserEvent::ListWorkspaceInvitations) +diff --git a/frontend/rust-lib/event-integration-test/tests/user/af_cloud_test/member_test.rs b/frontend/rust-lib/event-integration-test/tests/user/af_cloud_test/member_test.rs +index c5fc2479b..9eba50b40 100644 +--- a/frontend/rust-lib/event-integration-test/tests/user/af_cloud_test/member_test.rs ++++ b/frontend/rust-lib/event-integration-test/tests/user/af_cloud_test/member_test.rs +@@ -47,7 +47,7 @@ async fn af_cloud_add_workspace_member_test() { + assert_eq!(members[0].email, user_1.email); +  + test_1 +- .add_workspace_member(&user_1.workspace_id, &user_2.email) ++ .add_workspace_member(&user_1.workspace_id, &test_2) + .await; +  + let members = test_1.get_workspace_members(&user_1.workspace_id).await; +@@ -66,7 +66,7 @@ async fn af_cloud_delete_workspace_member_test() { + let user_2 = test_2.af_cloud_sign_up().await; +  + test_1 +- .add_workspace_member(&user_1.workspace_id, &user_2.email) ++ .add_workspace_member(&user_1.workspace_id, &test_2) + .await; +  + test_1 +@@ -88,7 +88,7 @@ async fn af_cloud_leave_workspace_test() { + let user_2 = test_2.af_cloud_sign_up().await; +  + test_1 +- .add_workspace_member(&user_1.workspace_id, &user_2.email) ++ .add_workspace_member(&user_1.workspace_id, &test_2) + .await; +  + // test_2 should have 2 workspace +diff --git a/frontend/rust-lib/event-integration-test/tests/user/af_cloud_test/workspace_test.rs b/frontend/rust-lib/event-integration-test/tests/user/af_cloud_test/workspace_test.rs +index af743e7ce..b72ceba33 100644 +--- a/frontend/rust-lib/event-integration-test/tests/user/af_cloud_test/workspace_test.rs ++++ b/frontend/rust-lib/event-integration-test/tests/user/af_cloud_test/workspace_test.rs +@@ -182,7 +182,7 @@ async fn af_cloud_different_open_same_workspace_test() { + } +  + client_1 +- .add_workspace_member(&owner_profile.workspace_id, &client_profile.email) ++ .add_workspace_member(&owner_profile.workspace_id, &client) + .await; + clients.push((client, client_profile)); + } +diff --git a/frontend/rust-lib/flowy-server/src/af_cloud/impls/user/cloud_service_impl.rs b/frontend/rust-lib/flowy-server/src/af_cloud/impls/user/cloud_service_impl.rs +index a7928a974..cbb006ce8 100644 +--- a/frontend/rust-lib/flowy-server/src/af_cloud/impls/user/cloud_service_impl.rs ++++ b/frontend/rust-lib/flowy-server/src/af_cloud/impls/user/cloud_service_impl.rs +@@ -6,8 +6,7 @@ use client_api::entity::billing_dto::{ + SubscriptionPlan, SubscriptionStatus, WorkspaceSubscriptionPlan, WorkspaceSubscriptionStatus, + }; + use client_api::entity::workspace_dto::{ +- CreateWorkspaceMember, CreateWorkspaceParam, PatchWorkspaceParam, WorkspaceMemberChangeset, +- WorkspaceMemberInvitation, ++ CreateWorkspaceParam, PatchWorkspaceParam, WorkspaceMemberChangeset, WorkspaceMemberInvitation, + }; + use client_api::entity::{ + AFRole, AFWorkspace, AFWorkspaceInvitation, AuthProvider, CollabParams, CreateCollabParams, +@@ -222,28 +221,6 @@ where + }) + } +  +- #[allow(deprecated)] +- fn add_workspace_member( +- &self, +- user_email: String, +- workspace_id: String, +- ) -> FutureResult<(), FlowyError> { +- let try_get_client = self.server.try_get_client(); +- FutureResult::new(async move { +- // TODO(zack): add_workspace_members will be deprecated after finishing the invite logic. Don't forget to remove the #[allow(deprecated)] +- try_get_client? +- .add_workspace_members( +- workspace_id, +- vec![CreateWorkspaceMember { +- email: user_email, +- role: AFRole::Member, +- }], +- ) +- .await?; +- Ok(()) +- }) +- } +- + fn invite_workspace_member( + &self, + invitee_email: String, +diff --git a/frontend/rust-lib/flowy-user-pub/src/cloud.rs b/frontend/rust-lib/flowy-user-pub/src/cloud.rs +index a97f7b28e..0508e5c40 100644 +--- a/frontend/rust-lib/flowy-user-pub/src/cloud.rs ++++ b/frontend/rust-lib/flowy-user-pub/src/cloud.rs +@@ -178,15 +178,6 @@ pub trait UserCloudService: Send + Sync + 'static { + /// Deletes a workspace owned by the user. + fn delete_workspace(&self, workspace_id: &str) -> FutureResult<(), FlowyError>; +  +- // Deprecated, use invite instead +- fn add_workspace_member( +- &self, +- user_email: String, +- workspace_id: String, +- ) -> FutureResult<(), FlowyError> { +- FutureResult::new(async { Ok(()) }) +- } +- + fn invite_workspace_member( + &self, + invitee_email: String, +diff --git a/frontend/rust-lib/flowy-user/src/event_handler.rs b/frontend/rust-lib/flowy-user/src/event_handler.rs +index b2c36d8c6..831289d1b 100644 +--- a/frontend/rust-lib/flowy-user/src/event_handler.rs ++++ b/frontend/rust-lib/flowy-user/src/event_handler.rs +@@ -623,19 +623,6 @@ pub async fn update_reminder_event_handler( + Ok(()) + } +  +-#[tracing::instrument(level = "debug", skip_all, err)] +-pub async fn add_workspace_member_handler( +- data: AFPluginData, +- manager: AFPluginState>, +-) -> Result<(), FlowyError> { +- let data = data.try_into_inner()?; +- let manager = upgrade_manager(manager)?; +- manager +- .add_workspace_member(data.email, data.workspace_id) +- .await?; +- Ok(()) +-} +- + #[tracing::instrument(level = "debug", skip_all, err)] + pub async fn delete_workspace_member_handler( + data: AFPluginData, +diff --git a/frontend/rust-lib/flowy-user/src/event_map.rs b/frontend/rust-lib/flowy-user/src/event_map.rs +index 42be2a256..7c7db18bc 100644 +--- a/frontend/rust-lib/flowy-user/src/event_map.rs ++++ b/frontend/rust-lib/flowy-user/src/event_map.rs +@@ -54,9 +54,6 @@ pub fn init(user_manager: Weak) -> AFPlugin { + .event(UserEvent::SetNotificationSettings, set_notification_settings) + .event(UserEvent::GetNotificationSettings, get_notification_settings) + .event(UserEvent::ImportAppFlowyDataFolder, import_appflowy_data_folder_handler) +- // Workspace member +- .event(UserEvent::AddWorkspaceMember, add_workspace_member_handler) // deprecated, use invite +- // instead + .event(UserEvent::GetMemberInfo, get_workspace_member_info) + .event(UserEvent::RemoveWorkspaceMember, delete_workspace_member_handler) + .event(UserEvent::GetWorkspaceMembers, get_workspace_members_handler) +@@ -196,9 +193,6 @@ pub enum UserEvent { + #[event(output = "NotificationSettingsPB")] + GetNotificationSettings = 36, +  +- #[event(input = "AddWorkspaceMemberPB")] +- AddWorkspaceMember = 37, +- + #[event(input = "RemoveWorkspaceMemberPB")] + RemoveWorkspaceMember = 38, +  +diff --git a/frontend/rust-lib/flowy-user/src/user_manager/manager_user_workspace.rs b/frontend/rust-lib/flowy-user/src/user_manager/manager_user_workspace.rs +index cee00fecd..0c22d28d4 100644 +--- a/frontend/rust-lib/flowy-user/src/user_manager/manager_user_workspace.rs ++++ b/frontend/rust-lib/flowy-user/src/user_manager/manager_user_workspace.rs +@@ -327,20 +327,6 @@ impl UserManager { + Ok(()) + } +  +- // deprecated, use invite instead +- pub async fn add_workspace_member( +- &self, +- user_email: String, +- workspace_id: String, +- ) -> FlowyResult<()> { +- self +- .cloud_services +- .get_user_service()? +- .add_workspace_member(user_email, workspace_id) +- .await?; +- Ok(()) +- } +- + pub async fn remove_workspace_member( + &self, + user_email: String,