feat: wip

This commit is contained in:
Zack Fu Zi Xiang 2024-03-07 19:47:45 +08:00
parent fbf4662c6c
commit 0b4b7519d0
No known key found for this signature in database
6 changed files with 26 additions and 7 deletions

View File

@ -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)

View File

@ -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;

View File

@ -181,7 +181,7 @@ where
})
}
// Deprecated
// Deprecated, use invite instead
fn add_workspace_member(
&self,
user_email: String,

View File

@ -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<AddWorkspaceMemberPB>,
@ -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<WorkspaceMemberInvitationPB>,
manager: AFPluginState<Weak<UserManager>>,
) -> 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!()

View File

@ -67,7 +67,7 @@ pub fn init(user_manager: Weak<UserManager>) -> 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,

View File

@ -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,