From 0b4b7519d0d1d1321aa059ae7d7e467b42e2d6e7 Mon Sep 17 00:00:00 2001 From: Zack Fu Zi Xiang Date: Thu, 7 Mar 2024 19:47:45 +0800 Subject: [PATCH] feat: wip --- .../rust-lib/event-integration/src/folder_event.rs | 14 ++++++++++++++ .../tests/user/af_cloud_test/member_test.rs | 4 ++++ .../src/af_cloud/impls/user/cloud_service_impl.rs | 2 +- frontend/rust-lib/flowy-user/src/event_handler.rs | 5 +++-- frontend/rust-lib/flowy-user/src/event_map.rs | 4 ++-- .../src/user_manager/manager_user_workspace.rs | 4 ++-- 6 files changed, 26 insertions(+), 7 deletions(-) diff --git a/frontend/rust-lib/event-integration/src/folder_event.rs b/frontend/rust-lib/event-integration/src/folder_event.rs index af426d1615..67e06386e6 100644 --- a/frontend/rust-lib/event-integration/src/folder_event.rs +++ b/frontend/rust-lib/event-integration/src/folder_event.rs @@ -13,6 +13,8 @@ use crate::event_builder::EventBuilder; use crate::EventIntegrationTest; impl EventIntegrationTest { + + // Deprecated, use invite instead pub async fn add_workspace_member(&self, workspace_id: &str, email: &str) { EventBuilder::new(self.clone()) .event(UserEvent::AddWorkspaceMember) @@ -24,6 +26,18 @@ impl EventIntegrationTest { .await; } + // Deprecated, use invite instead + pub async fn invite_workspace_member(&self, workspace_id: &str, email: &str) { + EventBuilder::new(self.clone()) + .event(UserEvent::InviteWorkspaceMembers) + .payload(AddWorkspaceMemberPB { + workspace_id: workspace_id.to_string(), + email: email.to_string(), + }) + .async_send() + .await; + } + pub async fn delete_workspace_member(&self, workspace_id: &str, email: &str) { EventBuilder::new(self.clone()) .event(UserEvent::RemoveWorkspaceMember) diff --git a/frontend/rust-lib/event-integration/tests/user/af_cloud_test/member_test.rs b/frontend/rust-lib/event-integration/tests/user/af_cloud_test/member_test.rs index fff097275a..58757bc798 100644 --- a/frontend/rust-lib/event-integration/tests/user/af_cloud_test/member_test.rs +++ b/frontend/rust-lib/event-integration/tests/user/af_cloud_test/member_test.rs @@ -1,6 +1,7 @@ use event_integration::user_event::user_localhost_af_cloud; use event_integration::EventIntegrationTest; +// Deprecated, use invite instead #[tokio::test] async fn af_cloud_add_workspace_member_test() { user_localhost_af_cloud().await; @@ -14,6 +15,8 @@ async fn af_cloud_add_workspace_member_test() { assert_eq!(members.len(), 1); assert_eq!(members[0].email, user_1.email); + + test_1 .add_workspace_member(&user_1.workspace_id, &user_2.email) .await; @@ -24,6 +27,7 @@ async fn af_cloud_add_workspace_member_test() { assert_eq!(members[1].email, user_2.email); } +// Deprecated, use invite instead #[tokio::test] async fn af_cloud_delete_workspace_member_test() { user_localhost_af_cloud().await; 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 586081b033..f473782f24 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 @@ -181,7 +181,7 @@ where }) } - // Deprecated + // Deprecated, use invite instead fn add_workspace_member( &self, user_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 778c3ec09a..18261e3f79 100644 --- a/frontend/rust-lib/flowy-user/src/event_handler.rs +++ b/frontend/rust-lib/flowy-user/src/event_handler.rs @@ -607,6 +607,7 @@ pub async fn update_reminder_event_handler( Ok(()) } +// Deprecated, use invite instead #[tracing::instrument(level = "debug", skip_all, err)] pub async fn add_workspace_member_handler( data: AFPluginData, @@ -711,14 +712,14 @@ pub async fn change_workspace_icon_handler( } #[tracing::instrument(level = "debug", skip_all, err)] -pub async fn invite_members_to_workspace_handler( +pub async fn invite_workspace_members_handler( param: AFPluginData, manager: AFPluginState>, ) -> Result<(), FlowyError> { let param = param.try_into_inner()?; let manager = upgrade_manager(manager)?; manager - .invite_member_to_workspace(param.workspace_id, param.invitee_email, param.role.into()) + .invite_workspace_members(param.workspace_id, param.invitee_email, param.role.into()) .await?; todo!() diff --git a/frontend/rust-lib/flowy-user/src/event_map.rs b/frontend/rust-lib/flowy-user/src/event_map.rs index 2eaa36623d..64e0cffecd 100644 --- a/frontend/rust-lib/flowy-user/src/event_map.rs +++ b/frontend/rust-lib/flowy-user/src/event_map.rs @@ -67,7 +67,7 @@ pub fn init(user_manager: Weak) -> AFPlugin { .event(UserEvent::RenameWorkspace, rename_workspace_handler) .event(UserEvent::ChangeWorkspaceIcon, change_workspace_icon_handler) - .event(UserEvent::InviteMembersToWorkspace, invite_members_to_workspace_handler) + .event(UserEvent::InviteWorkspaceMembers, invite_workspace_members_handler) .event(UserEvent::ListWorkspaceInvitations, list_workspace_invitations_handler) .event(UserEvent::AcceptWorkspaceInvitation, accept_workspace_invitations_handler) } @@ -216,7 +216,7 @@ pub enum UserEvent { ChangeWorkspaceIcon = 45, #[event(input = "WorkspaceMemberInvitationPB")] - InviteMembersToWorkspace = 46, + InviteWorkspaceMembers = 46, #[event(output = "RepeatedWorkspaceInvitationPB")] ListWorkspaceInvitations = 47, 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 138962a87b..1da57960e1 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 @@ -196,7 +196,7 @@ impl UserManager { Ok(()) } - pub async fn invite_member_to_workspace( + pub async fn invite_workspace_members( &self, workspace_id: String, invitee_email: String, @@ -229,7 +229,7 @@ impl UserManager { Ok(()) } - // deprecated, use invite instead + // Deprecated, use invite instead pub async fn add_workspace_member( &self, user_email: String,