Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

chore: open workspace with workspace auth type

Nathan4634b51edf1c
diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/home/workspaces/workspace_menu_bottom_sheet.dart b/frontend/appflowy_flutter/lib/mobile/presentation/home/workspaces/workspace_menu_bottom_sheet.dart
index d306f48964..9743da966e 100644
--- a/frontend/appflowy_flutter/lib/mobile/presentation/home/workspaces/workspace_menu_bottom_sheet.dart
+++ b/frontend/appflowy_flutter/lib/mobile/presentation/home/workspaces/workspace_menu_bottom_sheet.dart
@@ -123,7 +123,7 @@ class _CreateWorkspaceButton extends StatelessWidget {
context.read<UserWorkspaceBloc>().add(
UserWorkspaceEvent.createWorkspace(
name,
- AuthTypePB.Server,
+ AuthTypePB.Local,
),
);
},
diff --git a/frontend/appflowy_flutter/lib/user/application/user_service.dart b/frontend/appflowy_flutter/lib/user/application/user_service.dart
index 3ec181e009..918350d4af 100644
--- a/frontend/appflowy_flutter/lib/user/application/user_service.dart
+++ b/frontend/appflowy_flutter/lib/user/application/user_service.dart
@@ -127,7 +127,7 @@ class UserBackendService implements IUserBackendService {
) {
final payload = OpenUserWorkspacePB()
..workspaceId = workspaceId
- ..authType = authType;
+ ..workspaceAuthType = authType;
return UserEventOpenWorkspace(payload).send();
}
diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/workspace/_sidebar_workspace_menu.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/workspace/_sidebar_workspace_menu.dart
index 4ff5ccbf67..04eb701a66 100644
--- a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/workspace/_sidebar_workspace_menu.dart
+++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/workspace/_sidebar_workspace_menu.dart
@@ -389,7 +389,7 @@ class _CreateWorkspaceButton extends StatelessWidget {
workspaceBloc.add(
UserWorkspaceEvent.createWorkspace(
name,
- AuthTypePB.Server,
+ AuthTypePB.Local,
),
);
},
diff --git a/frontend/appflowy_flutter/macos/Podfile.lock b/frontend/appflowy_flutter/macos/Podfile.lock
index b4a1a3d20d..f4bedfef79 100644
--- a/frontend/appflowy_flutter/macos/Podfile.lock
+++ b/frontend/appflowy_flutter/macos/Podfile.lock
@@ -150,7 +150,7 @@ SPEC CHECKSUMS:
bitsdojo_window_macos: 44e3b8fe3dd463820e0321f6256c5b1c16bb6a00
connectivity_plus: 18d3c32514c886e046de60e9c13895109866c747
desktop_drop: 69eeff437544aa619c8db7f4481b3a65f7696898
- device_info_plus: ce1b7762849d3ec103d0e0517299f2db7ad60720
+ device_info_plus: 1b14eed9bf95428983aed283a8d51cce3d8c4215
file_selector_macos: cc3858c981fe6889f364731200d6232dac1d812d
flowy_infra_ui: 03301a39ad118771adbf051a664265c61c507f38
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
diff --git a/frontend/rust-lib/event-integration-test/src/user_event.rs b/frontend/rust-lib/event-integration-test/src/user_event.rs
index ab10bb7083..821c3c9a1d 100644
--- a/frontend/rust-lib/event-integration-test/src/user_event.rs
+++ b/frontend/rust-lib/event-integration-test/src/user_event.rs
@@ -283,7 +283,7 @@ impl EventIntegrationTest {
pub async fn open_workspace(&self, workspace_id: &str, auth_type: AuthTypePB) {
let payload = OpenUserWorkspacePB {
workspace_id: workspace_id.to_string(),
- auth_type,
+ workspace_auth_type: auth_type,
};
EventBuilder::new(self.clone())
.event(UserEvent::OpenWorkspace)
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 7cc3f5d88c..4e46f310c5 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
@@ -656,6 +656,7 @@ fn to_user_workspace(af_workspace: AFWorkspace) -> UserWorkspace {
icon: af_workspace.icon,
member_count: af_workspace.member_count.unwrap_or(0),
role: af_workspace.role.map(|r| r.into()),
+ workspace_type: AuthType::AppFlowyCloud,
}
}
diff --git a/frontend/rust-lib/flowy-user-pub/src/entities.rs b/frontend/rust-lib/flowy-user-pub/src/entities.rs
index 061bda56f5..a870b9c0b0 100644
--- a/frontend/rust-lib/flowy-user-pub/src/entities.rs
+++ b/frontend/rust-lib/flowy-user-pub/src/entities.rs
@@ -114,6 +114,12 @@ pub struct UserWorkspace {
pub member_count: i64,
#[serde(default)]
pub role: Option<Role>,
+ #[serde(default = "default_workspace_type")]
+ pub workspace_type: AuthType,
+}
+
+fn default_workspace_type() -> AuthType {
+ AuthType::AppFlowyCloud
}
impl UserWorkspace {
@@ -131,6 +137,7 @@ impl UserWorkspace {
icon: "".to_string(),
member_count: 1,
role: Some(Role::Owner),
+ workspace_type: AuthType::Local,
}
}
}
diff --git a/frontend/rust-lib/flowy-user-pub/src/session.rs b/frontend/rust-lib/flowy-user-pub/src/session.rs
index 4c2668477a..83a5670ddb 100644
--- a/frontend/rust-lib/flowy-user-pub/src/session.rs
+++ b/frontend/rust-lib/flowy-user-pub/src/session.rs
@@ -1,4 +1,4 @@
-use crate::entities::{UserAuthResponse, UserWorkspace};
+use crate::entities::{AuthType, UserAuthResponse, UserWorkspace};
use base64::engine::general_purpose::STANDARD;
use base64::Engine;
use chrono::Utc;
@@ -77,6 +77,7 @@ impl<'de> Visitor<'de> for SessionVisitor {
icon: "".to_owned(),
member_count: 1,
role: None,
+ workspace_type: AuthType::Local,
})
}
}
diff --git a/frontend/rust-lib/flowy-user-pub/src/sql/workspace_sql.rs b/frontend/rust-lib/flowy-user-pub/src/sql/workspace_sql.rs
index 80c99eb7e6..27f63e3de6 100644
--- a/frontend/rust-lib/flowy-user-pub/src/sql/workspace_sql.rs
+++ b/frontend/rust-lib/flowy-user-pub/src/sql/workspace_sql.rs
@@ -149,6 +149,7 @@ impl From<UserWorkspaceTable> for UserWorkspace {
icon: value.icon,
member_count: value.member_count,
role: value.role.map(|v| v.into()),
+ workspace_type: AuthType::from(value.workspace_type),
}
}
}
diff --git a/frontend/rust-lib/flowy-user/src/entities/user_profile.rs b/frontend/rust-lib/flowy-user/src/entities/user_profile.rs
index a117d0839e..77d92fb33a 100644
--- a/frontend/rust-lib/flowy-user/src/entities/user_profile.rs
+++ b/frontend/rust-lib/flowy-user/src/entities/user_profile.rs
@@ -156,14 +156,10 @@ pub struct RepeatedUserWorkspacePB {
pub items: Vec<UserWorkspacePB>,
}
-impl From<(AuthType, Vec<UserWorkspace>)> for RepeatedUserWorkspacePB {
- fn from(value: (AuthType, Vec<UserWorkspace>)) -> Self {
- let (auth_type, workspaces) = value;
+impl From<Vec<UserWorkspace>> for RepeatedUserWorkspacePB {
+ fn from(workspaces: Vec<UserWorkspace>) -> Self {
Self {
- items: workspaces
- .into_iter()
- .map(|w| UserWorkspacePB::from((auth_type, w)))
- .collect(),
+ items: workspaces.into_iter().map(UserWorkspacePB::from).collect(),
}
}
}
@@ -193,16 +189,16 @@ pub struct UserWorkspacePB {
pub workspace_auth_type: AuthTypePB,
}
-impl From<(AuthType, UserWorkspace)> for UserWorkspacePB {
- fn from(value: (AuthType, UserWorkspace)) -> Self {
+impl From<UserWorkspace> for UserWorkspacePB {
+ fn from(workspace: UserWorkspace) -> Self {
Self {
- workspace_id: value.1.id,
- name: value.1.name,
- created_at_timestamp: value.1.created_at.timestamp(),
- icon: value.1.icon,
- member_count: value.1.member_count,
- role: value.1.role.map(AFRolePB::from),
- workspace_auth_type: AuthTypePB::from(value.0),
+ workspace_id: workspace.id,
+ name: workspace.name,
+ created_at_timestamp: workspace.created_at.timestamp(),
+ icon: workspace.icon,
+ member_count: workspace.member_count,
+ role: workspace.role.map(AFRolePB::from),
+ workspace_auth_type: AuthTypePB::from(workspace.workspace_type),
}
}
}
diff --git a/frontend/rust-lib/flowy-user/src/entities/workspace.rs b/frontend/rust-lib/flowy-user/src/entities/workspace.rs
index 99544eede4..2781f29c09 100644
--- a/frontend/rust-lib/flowy-user/src/entities/workspace.rs
+++ b/frontend/rust-lib/flowy-user/src/entities/workspace.rs
@@ -200,7 +200,7 @@ pub struct OpenUserWorkspacePB {
pub workspace_id: String,
#[pb(index = 2)]
- pub auth_type: AuthTypePB,
+ pub workspace_auth_type: AuthTypePB,
}
#[derive(ProtoBuf, Default, Clone, Validate)]
diff --git a/frontend/rust-lib/flowy-user/src/event_handler.rs b/frontend/rust-lib/flowy-user/src/event_handler.rs
index bf865f24f0..cbcf6f4477 100644
--- a/frontend/rust-lib/flowy-user/src/event_handler.rs
+++ b/frontend/rust-lib/flowy-user/src/event_handler.rs
@@ -439,10 +439,7 @@ pub async fn get_all_workspace_handler(
.get_all_user_workspaces(profile.uid, profile.auth_type)
.await?;
- data_result_ok(RepeatedUserWorkspacePB::from((
- profile.auth_type,
- user_workspaces,
- )))
+ data_result_ok(RepeatedUserWorkspacePB::from(user_workspaces))
}
#[tracing::instrument(level = "info", skip(data, manager), err)]
@@ -454,7 +451,7 @@ pub async fn open_workspace_handler(
let params = data.try_into_inner()?;
let workspace_id = Uuid::from_str(&params.workspace_id)?;
manager
- .open_workspace(&workspace_id, AuthType::from(params.auth_type))
+ .open_workspace(&workspace_id, AuthType::from(params.workspace_auth_type))
.await?;
Ok(())
}
@@ -627,7 +624,7 @@ pub async fn create_workspace_handler(
let auth_type = AuthType::from(data.auth_type);
let manager = upgrade_manager(manager)?;
let new_workspace = manager.create_workspace(&data.name, auth_type).await?;
- data_result_ok(UserWorkspacePB::from((auth_type, new_workspace)))
+ data_result_ok(UserWorkspacePB::from(new_workspace))
}
#[tracing::instrument(level = "debug", skip_all, err)]
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 c641fde831..0101ef299e 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
@@ -451,7 +451,7 @@ impl UserManager {
);
// only send notification if there were real changes
if let Ok(updated_list) = select_all_user_workspace(uid, &mut conn) {
- let repeated_pb = RepeatedUserWorkspacePB::from((auth_copy, updated_list));
+ let repeated_pb = RepeatedUserWorkspacePB::from(updated_list);
send_notification(&uid.to_string(), UserNotification::DidUpdateUserWorkspaces)
.payload(repeated_pb)
.send();