From 1e9137fcfe8acc9f0ecca217a751158f53979b4e Mon Sep 17 00:00:00 2001 From: "Nathan.fooo" <86001920+appflowy@users.noreply.github.com> Date: Mon, 23 Oct 2023 11:43:31 +0800 Subject: [PATCH] chore: update client api commit id (#3745) * chore: update client api commit id * chore: fix test * chore: remove check_visual_studio_installation task * chore: update client api --- frontend/appflowy_tauri/src-tauri/Cargo.lock | 65 ++++++++++++++-- frontend/appflowy_tauri/src-tauri/Cargo.toml | 2 +- frontend/rust-lib/Cargo.lock | 75 +++++++++++++++++-- frontend/rust-lib/Cargo.toml | 2 +- .../rust-lib/event-integration/src/lib.rs | 23 +++--- .../tests/database/supabase_test/helper.rs | 3 +- .../tests/user/supabase_test/auth_test.rs | 8 +- .../src/deps_resolve/document_deps.rs | 8 ++ .../flowy-core/src/integrate/trait_impls.rs | 32 ++++++-- frontend/rust-lib/flowy-core/src/lib.rs | 5 +- .../rust-lib/flowy-database-deps/src/cloud.rs | 2 + .../rust-lib/flowy-database2/src/manager.rs | 16 +++- .../rust-lib/flowy-document-deps/src/cloud.rs | 13 +++- .../rust-lib/flowy-document2/src/manager.rs | 16 +++- .../flowy-document2/tests/document/util.rs | 18 ++++- .../src/af_cloud/impls/database.rs | 11 ++- .../src/af_cloud/impls/document.rs | 17 ++++- .../src/af_cloud/impls/file_storage.rs | 8 +- .../flowy-server/src/af_cloud/impls/folder.rs | 4 +- .../flowy-server/src/af_cloud/impls/user.rs | 26 ++++--- .../src/local_server/impls/database.rs | 2 + .../src/local_server/impls/document.rs | 13 +++- .../flowy-server/src/supabase/api/database.rs | 2 + .../flowy-server/src/supabase/api/document.rs | 13 +++- .../tests/supabase_test/database_test.rs | 2 +- frontend/rust-lib/flowy-user/src/manager.rs | 14 +++- 26 files changed, 320 insertions(+), 80 deletions(-) diff --git a/frontend/appflowy_tauri/src-tauri/Cargo.lock b/frontend/appflowy_tauri/src-tauri/Cargo.lock index 697f49addf..37005a6716 100644 --- a/frontend/appflowy_tauri/src-tauri/Cargo.lock +++ b/frontend/appflowy_tauri/src-tauri/Cargo.lock @@ -762,7 +762,7 @@ dependencies = [ [[package]] name = "client-api" version = "0.1.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=52b82e68#52b82e68f6e61e9e38606b9110d782870ee911e4" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7a309c6f69d8b34709292052e9ef0561e16c82a1#7a309c6f69d8b34709292052e9ef0561e16c82a1" dependencies = [ "anyhow", "bytes", @@ -775,6 +775,7 @@ dependencies = [ "gotrue-entity", "lib0", "mime", + "mime_guess", "parking_lot", "realtime-entity", "reqwest", @@ -1437,15 +1438,17 @@ checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" [[package]] name = "database-entity" version = "0.1.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=52b82e68#52b82e68f6e61e9e38606b9110d782870ee911e4" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7a309c6f69d8b34709292052e9ef0561e16c82a1#7a309c6f69d8b34709292052e9ef0561e16c82a1" dependencies = [ "anyhow", "chrono", "collab-entity", "serde", "serde_json", + "serde_repr", "sqlx", "thiserror", + "tracing", "uuid", "validator", ] @@ -2778,7 +2781,7 @@ dependencies = [ [[package]] name = "gotrue" version = "0.1.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=52b82e68#52b82e68f6e61e9e38606b9110d782870ee911e4" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7a309c6f69d8b34709292052e9ef0561e16c82a1#7a309c6f69d8b34709292052e9ef0561e16c82a1" dependencies = [ "anyhow", "futures-util", @@ -2794,9 +2797,11 @@ dependencies = [ [[package]] name = "gotrue-entity" version = "0.1.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=52b82e68#52b82e68f6e61e9e38606b9110d782870ee911e4" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7a309c6f69d8b34709292052e9ef0561e16c82a1#7a309c6f69d8b34709292052e9ef0561e16c82a1" dependencies = [ "anyhow", + "jsonwebtoken", + "lazy_static", "reqwest", "serde", "serde_json", @@ -3227,7 +3232,7 @@ dependencies = [ [[package]] name = "infra" version = "0.1.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=52b82e68#52b82e68f6e61e9e38606b9110d782870ee911e4" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7a309c6f69d8b34709292052e9ef0561e16c82a1#7a309c6f69d8b34709292052e9ef0561e16c82a1" dependencies = [ "anyhow", "reqwest", @@ -3373,6 +3378,20 @@ dependencies = [ "treediff", ] +[[package]] +name = "jsonwebtoken" +version = "8.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6971da4d9c3aa03c3d8f3ff0f4155b534aad021292003895a469716b2a230378" +dependencies = [ + "base64 0.21.2", + "pem", + "ring", + "serde", + "serde_json", + "simple_asn1", +] + [[package]] name = "kuchiki" version = "0.8.1" @@ -3894,6 +3913,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "num-bigint" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + [[package]] name = "num-integer" version = "0.1.45" @@ -4190,6 +4220,15 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" +[[package]] +name = "pem" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8" +dependencies = [ + "base64 0.13.1", +] + [[package]] name = "percent-encoding" version = "2.3.0" @@ -4876,7 +4915,7 @@ dependencies = [ [[package]] name = "realtime-entity" version = "0.1.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=52b82e68#52b82e68f6e61e9e38606b9110d782870ee911e4" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7a309c6f69d8b34709292052e9ef0561e16c82a1#7a309c6f69d8b34709292052e9ef0561e16c82a1" dependencies = [ "bytes", "collab", @@ -5598,7 +5637,7 @@ dependencies = [ [[package]] name = "shared_entity" version = "0.1.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=52b82e68#52b82e68f6e61e9e38606b9110d782870ee911e4" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7a309c6f69d8b34709292052e9ef0561e16c82a1#7a309c6f69d8b34709292052e9ef0561e16c82a1" dependencies = [ "anyhow", "database-entity", @@ -5653,6 +5692,18 @@ version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "420acb44afdae038210c99e69aae24109f32f15500aa708e81d46c9f29d55fcf" +[[package]] +name = "simple_asn1" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adc4e5204eb1910f40f9cfa375f6f05b68c3abac4b6fd879c8ff5e7ae8a0a085" +dependencies = [ + "num-bigint", + "num-traits", + "thiserror", + "time", +] + [[package]] name = "siphasher" version = "0.3.10" diff --git a/frontend/appflowy_tauri/src-tauri/Cargo.toml b/frontend/appflowy_tauri/src-tauri/Cargo.toml index 28c3327054..ea85a88118 100644 --- a/frontend/appflowy_tauri/src-tauri/Cargo.toml +++ b/frontend/appflowy_tauri/src-tauri/Cargo.toml @@ -38,7 +38,7 @@ custom-protocol = ["tauri/custom-protocol"] # Run the script: # scripts/tool/update_client_api_rev.sh new_rev_id # ⚠️⚠️⚠️️ -client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "52b82e68" } +client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "7a309c6f69d8b34709292052e9ef0561e16c82a1" } # Please use the following script to update collab. # Working directory: frontend # diff --git a/frontend/rust-lib/Cargo.lock b/frontend/rust-lib/Cargo.lock index 900fa89bec..c2d899112a 100644 --- a/frontend/rust-lib/Cargo.lock +++ b/frontend/rust-lib/Cargo.lock @@ -660,7 +660,7 @@ dependencies = [ [[package]] name = "client-api" version = "0.1.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=52b82e68#52b82e68f6e61e9e38606b9110d782870ee911e4" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7a309c6f69d8b34709292052e9ef0561e16c82a1#7a309c6f69d8b34709292052e9ef0561e16c82a1" dependencies = [ "anyhow", "bytes", @@ -673,6 +673,7 @@ dependencies = [ "gotrue-entity", "lib0", "mime", + "mime_guess", "parking_lot", "realtime-entity", "reqwest", @@ -1264,15 +1265,17 @@ checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" [[package]] name = "database-entity" version = "0.1.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=52b82e68#52b82e68f6e61e9e38606b9110d782870ee911e4" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7a309c6f69d8b34709292052e9ef0561e16c82a1#7a309c6f69d8b34709292052e9ef0561e16c82a1" dependencies = [ "anyhow", "chrono", "collab-entity", "serde", "serde_json", + "serde_repr", "sqlx", "thiserror", + "tracing", "uuid", "validator", ] @@ -2437,7 +2440,7 @@ dependencies = [ [[package]] name = "gotrue" version = "0.1.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=52b82e68#52b82e68f6e61e9e38606b9110d782870ee911e4" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7a309c6f69d8b34709292052e9ef0561e16c82a1#7a309c6f69d8b34709292052e9ef0561e16c82a1" dependencies = [ "anyhow", "futures-util", @@ -2453,9 +2456,11 @@ dependencies = [ [[package]] name = "gotrue-entity" version = "0.1.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=52b82e68#52b82e68f6e61e9e38606b9110d782870ee911e4" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7a309c6f69d8b34709292052e9ef0561e16c82a1#7a309c6f69d8b34709292052e9ef0561e16c82a1" dependencies = [ "anyhow", + "jsonwebtoken", + "lazy_static", "reqwest", "serde", "serde_json", @@ -2811,7 +2816,7 @@ dependencies = [ [[package]] name = "infra" version = "0.1.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=52b82e68#52b82e68f6e61e9e38606b9110d782870ee911e4" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7a309c6f69d8b34709292052e9ef0561e16c82a1#7a309c6f69d8b34709292052e9ef0561e16c82a1" dependencies = [ "anyhow", "reqwest", @@ -2885,6 +2890,20 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "jsonwebtoken" +version = "8.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6971da4d9c3aa03c3d8f3ff0f4155b534aad021292003895a469716b2a230378" +dependencies = [ + "base64 0.21.3", + "pem", + "ring", + "serde", + "serde_json", + "simple_asn1", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -3309,6 +3328,27 @@ dependencies = [ "winapi", ] +[[package]] +name = "num-bigint" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.16" @@ -3517,6 +3557,15 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" +[[package]] +name = "pem" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8" +dependencies = [ + "base64 0.13.1", +] + [[package]] name = "percent-encoding" version = "2.3.0" @@ -4202,7 +4251,7 @@ dependencies = [ [[package]] name = "realtime-entity" version = "0.1.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=52b82e68#52b82e68f6e61e9e38606b9110d782870ee911e4" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7a309c6f69d8b34709292052e9ef0561e16c82a1#7a309c6f69d8b34709292052e9ef0561e16c82a1" dependencies = [ "bytes", "collab", @@ -4823,7 +4872,7 @@ dependencies = [ [[package]] name = "shared_entity" version = "0.1.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=52b82e68#52b82e68f6e61e9e38606b9110d782870ee911e4" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7a309c6f69d8b34709292052e9ef0561e16c82a1#7a309c6f69d8b34709292052e9ef0561e16c82a1" dependencies = [ "anyhow", "database-entity", @@ -4872,6 +4921,18 @@ version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "420acb44afdae038210c99e69aae24109f32f15500aa708e81d46c9f29d55fcf" +[[package]] +name = "simple_asn1" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adc4e5204eb1910f40f9cfa375f6f05b68c3abac4b6fd879c8ff5e7ae8a0a085" +dependencies = [ + "num-bigint", + "num-traits", + "thiserror", + "time", +] + [[package]] name = "siphasher" version = "0.3.11" diff --git a/frontend/rust-lib/Cargo.toml b/frontend/rust-lib/Cargo.toml index 491f3cd4fc..561fdfeb7c 100644 --- a/frontend/rust-lib/Cargo.toml +++ b/frontend/rust-lib/Cargo.toml @@ -82,7 +82,7 @@ incremental = false # Run the script: # scripts/tool/update_client_api_rev.sh new_rev_id # ⚠️⚠️⚠️️ -client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "52b82e68" } +client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "7a309c6f69d8b34709292052e9ef0561e16c82a1" } # Please use the following script to update collab. # Working directory: frontend # diff --git a/frontend/rust-lib/event-integration/src/lib.rs b/frontend/rust-lib/event-integration/src/lib.rs index 373f65e001..18203bd9de 100644 --- a/frontend/rust-lib/event-integration/src/lib.rs +++ b/frontend/rust-lib/event-integration/src/lib.rs @@ -87,9 +87,10 @@ impl FlowyCoreTest { } pub async fn get_document_update(&self, document_id: &str) -> Vec { + let workspace_id = self.user_manager.workspace_id().unwrap(); let cloud_service = self.document_manager.get_cloud_service().clone(); let remote_updates = cloud_service - .get_document_updates(document_id) + .get_document_updates(document_id, &workspace_id) .await .unwrap(); @@ -212,7 +213,7 @@ impl FlowyCoreTest { let mut map = HashMap::new(); map.insert(USER_SIGN_IN_URL.to_string(), sign_in_url); - map.insert(USER_DEVICE_ID.to_string(), uuid::Uuid::new_v4().to_string()); + map.insert(USER_DEVICE_ID.to_string(), Uuid::new_v4().to_string()); let payload = OauthSignInPB { map, auth_type: AuthTypePB::AFCloud, @@ -261,7 +262,7 @@ impl FlowyCoreTest { .event(FolderEvent::GetCurrentWorkspace) .async_send() .await - .parse::() + .parse::() } pub async fn get_all_workspace_views(&self) -> Vec { @@ -269,7 +270,7 @@ impl FlowyCoreTest { .event(FolderEvent::ReadWorkspaceViews) .async_send() .await - .parse::() + .parse::() .items } @@ -281,7 +282,7 @@ impl FlowyCoreTest { }) .async_send() .await - .parse::() + .parse::() } pub async fn delete_view(&self, view_id: &str) { @@ -333,7 +334,7 @@ impl FlowyCoreTest { .payload(payload) .async_send() .await - .parse::() + .parse::() } pub async fn create_document( @@ -391,7 +392,7 @@ impl FlowyCoreTest { .payload(payload) .async_send() .await - .parse::() + .parse::() } pub async fn open_database(&self, view_id: &str) { @@ -434,7 +435,7 @@ impl FlowyCoreTest { .payload(payload) .async_send() .await - .parse::() + .parse::() } pub async fn create_calendar( @@ -459,7 +460,7 @@ impl FlowyCoreTest { .payload(payload) .async_send() .await - .parse::() + .parse::() } pub async fn get_database(&self, view_id: &str) -> DatabasePB { @@ -470,7 +471,7 @@ impl FlowyCoreTest { }) .async_send() .await - .parse::() + .parse::() } pub async fn get_all_database_fields(&self, view_id: &str) -> RepeatedFieldPB { @@ -836,7 +837,7 @@ impl FlowyCoreTest { }) .async_send() .await - .parse::() + .parse::() } } diff --git a/frontend/rust-lib/event-integration/tests/database/supabase_test/helper.rs b/frontend/rust-lib/event-integration/tests/database/supabase_test/helper.rs index 250ef4546f..c146644da2 100644 --- a/frontend/rust-lib/event-integration/tests/database/supabase_test/helper.rs +++ b/frontend/rust-lib/event-integration/tests/database/supabase_test/helper.rs @@ -71,9 +71,10 @@ impl FlowySupabaseDatabaseTest { } pub async fn get_database_collab_update(&self, database_id: &str) -> Vec { + let workspace_id = self.user_manager.workspace_id().unwrap(); let cloud_service = self.database_manager.get_cloud_service().clone(); let remote_updates = cloud_service - .get_collab_update(database_id, CollabType::Database) + .get_collab_update(database_id, CollabType::Database, &workspace_id) .await .unwrap(); diff --git a/frontend/rust-lib/event-integration/tests/user/supabase_test/auth_test.rs b/frontend/rust-lib/event-integration/tests/user/supabase_test/auth_test.rs index c64ecf2b77..2027a09192 100644 --- a/frontend/rust-lib/event-integration/tests/user/supabase_test/auth_test.rs +++ b/frontend/rust-lib/event-integration/tests/user/supabase_test/auth_test.rs @@ -273,12 +273,13 @@ async fn migrate_anon_document_on_cloud_signup() { let _ = test.supabase_party_sign_up().await; + let workspace_id = test.user_manager.workspace_id().unwrap(); // After sign up, the documents should be migrated to the cloud // So, we can get the document data from the cloud let data: DocumentData = test .document_manager .get_cloud_service() - .get_document_data(&view.id) + .get_document_data(&view.id, &workspace_id) .await .unwrap() .unwrap(); @@ -372,6 +373,7 @@ async fn migrate_anon_data_on_cloud_signup() { let rows = editor.get_rows(&database_view.id).await.unwrap(); assert_eq!(rows.len(), 3); + let workspace_id = test.user_manager.workspace_id().unwrap(); if i == 0 { let first_row = rows.first().unwrap().as_ref(); let icon_url = first_row.meta.icon_url.clone().unwrap(); @@ -381,7 +383,7 @@ async fn migrate_anon_data_on_cloud_signup() { let document_data: DocumentData = test .document_manager .get_cloud_service() - .get_document_data(&document_id) + .get_document_data(&document_id, &workspace_id) .await .unwrap() .unwrap(); @@ -407,7 +409,7 @@ async fn migrate_anon_data_on_cloud_signup() { } assert!(cloud_service - .get_collab_update(&database_id, CollabType::Database) + .get_collab_update(&database_id, CollabType::Database, &workspace_id) .await .is_ok()); } diff --git a/frontend/rust-lib/flowy-core/src/deps_resolve/document_deps.rs b/frontend/rust-lib/flowy-core/src/deps_resolve/document_deps.rs index 7673e011d3..ce9b2ae9da 100644 --- a/frontend/rust-lib/flowy-core/src/deps_resolve/document_deps.rs +++ b/frontend/rust-lib/flowy-core/src/deps_resolve/document_deps.rs @@ -38,6 +38,14 @@ impl DocumentUser for DocumentUserImpl { .user_id() } + fn workspace_id(&self) -> Result { + self + .0 + .upgrade() + .ok_or(FlowyError::internal().with_context("Unexpected error: UserSession is None"))? + .workspace_id() + } + fn token(&self) -> Result, FlowyError> { self .0 diff --git a/frontend/rust-lib/flowy-core/src/integrate/trait_impls.rs b/frontend/rust-lib/flowy-core/src/integrate/trait_impls.rs index 0b02424f43..bd4df22ff4 100644 --- a/frontend/rust-lib/flowy-core/src/integrate/trait_impls.rs +++ b/frontend/rust-lib/flowy-core/src/integrate/trait_impls.rs @@ -190,13 +190,15 @@ impl DatabaseCloudService for ServerProvider { &self, object_id: &str, collab_type: CollabType, + workspace_id: &str, ) -> FutureResult { + let workspace_id = workspace_id.to_string(); let server = self.get_server(&self.get_server_type()); let database_id = object_id.to_string(); FutureResult::new(async move { server? .database_service() - .get_collab_update(&database_id, collab_type) + .get_collab_update(&database_id, collab_type, &workspace_id) .await }) } @@ -205,12 +207,14 @@ impl DatabaseCloudService for ServerProvider { &self, object_ids: Vec, object_ty: CollabType, + workspace_id: &str, ) -> FutureResult { + let workspace_id = workspace_id.to_string(); let server = self.get_server(&self.get_server_type()); FutureResult::new(async move { server? .database_service() - .batch_get_collab_updates(object_ids, object_ty) + .batch_get_collab_updates(object_ids, object_ty, &workspace_id) .await }) } @@ -232,13 +236,18 @@ impl DatabaseCloudService for ServerProvider { } impl DocumentCloudService for ServerProvider { - fn get_document_updates(&self, document_id: &str) -> FutureResult>, Error> { - let server = self.get_server(&self.get_server_type()); + fn get_document_updates( + &self, + document_id: &str, + workspace_id: &str, + ) -> FutureResult>, Error> { + let workspace_id = workspace_id.to_string(); let document_id = document_id.to_string(); + let server = self.get_server(&self.get_server_type()); FutureResult::new(async move { server? .document_service() - .get_document_updates(&document_id) + .get_document_updates(&document_id, &workspace_id) .await }) } @@ -247,24 +256,31 @@ impl DocumentCloudService for ServerProvider { &self, document_id: &str, limit: usize, + workspace_id: &str, ) -> FutureResult, Error> { + let workspace_id = workspace_id.to_string(); let server = self.get_server(&self.get_server_type()); let document_id = document_id.to_string(); FutureResult::new(async move { server? .document_service() - .get_document_snapshots(&document_id, limit) + .get_document_snapshots(&document_id, limit, &workspace_id) .await }) } - fn get_document_data(&self, document_id: &str) -> FutureResult, Error> { + fn get_document_data( + &self, + document_id: &str, + workspace_id: &str, + ) -> FutureResult, Error> { + let workspace_id = workspace_id.to_string(); let server = self.get_server(&self.get_server_type()); let document_id = document_id.to_string(); FutureResult::new(async move { server? .document_service() - .get_document_data(&document_id) + .get_document_data(&document_id, &workspace_id) .await }) } diff --git a/frontend/rust-lib/flowy-core/src/lib.rs b/frontend/rust-lib/flowy-core/src/lib.rs index 1bb72f1c26..de97c12a51 100644 --- a/frontend/rust-lib/flowy-core/src/lib.rs +++ b/frontend/rust-lib/flowy-core/src/lib.rs @@ -125,6 +125,7 @@ impl AppFlowyCore { server_provider.clone(), Arc::downgrade(&collab_builder), ); + collab_builder .set_snapshot_persistence(Arc::new(SnapshotDBImpl(Arc::downgrade(&user_manager)))); @@ -179,8 +180,8 @@ impl AppFlowyCore { let cloned_user_session = Arc::downgrade(&user_manager); runtime.block_on(async move { - if let Some(user_session) = cloned_user_session.upgrade() { - if let Err(err) = user_session + if let Some(user_manager) = cloned_user_session.upgrade() { + if let Err(err) = user_manager .init(user_status_callback, collab_interact_impl) .await { diff --git a/frontend/rust-lib/flowy-database-deps/src/cloud.rs b/frontend/rust-lib/flowy-database-deps/src/cloud.rs index bae09c5b30..0a679a4ba5 100644 --- a/frontend/rust-lib/flowy-database-deps/src/cloud.rs +++ b/frontend/rust-lib/flowy-database-deps/src/cloud.rs @@ -16,12 +16,14 @@ pub trait DatabaseCloudService: Send + Sync { &self, object_id: &str, collab_type: CollabType, + workspace_id: &str, ) -> FutureResult; fn batch_get_collab_updates( &self, object_ids: Vec, object_ty: CollabType, + workspace_id: &str, ) -> FutureResult; fn get_collab_snapshots( diff --git a/frontend/rust-lib/flowy-database2/src/manager.rs b/frontend/rust-lib/flowy-database2/src/manager.rs index d35c81048c..96dd331e88 100644 --- a/frontend/rust-lib/flowy-database2/src/manager.rs +++ b/frontend/rust-lib/flowy-database2/src/manager.rs @@ -76,11 +76,12 @@ impl DatabaseManager { pub async fn initialize( &self, uid: i64, - _workspace_id: String, + workspace_id: String, database_views_aggregate_id: String, ) -> FlowyResult<()> { let collab_db = self.user.collab_db(uid)?; let collab_builder = UserDatabaseCollabServiceImpl { + workspace_id: workspace_id.clone(), collab_builder: self.collab_builder.clone(), cloud_service: self.cloud_service.clone(), }; @@ -92,7 +93,11 @@ impl DatabaseManager { trace!("workspace database not exist, try to fetch from remote"); match self .cloud_service - .get_collab_update(&database_views_aggregate_id, CollabType::WorkspaceDatabase) + .get_collab_update( + &database_views_aggregate_id, + CollabType::WorkspaceDatabase, + &workspace_id, + ) .await { Ok(updates) => { @@ -370,6 +375,7 @@ fn subscribe_block_event(workspace_database: &WorkspaceDatabase) { } struct UserDatabaseCollabServiceImpl { + workspace_id: String, collab_builder: Arc, cloud_service: Arc, } @@ -380,6 +386,7 @@ impl DatabaseCollabService for UserDatabaseCollabServiceImpl { object_id: &str, object_ty: CollabType, ) -> CollabFuture> { + let workspace_id = self.workspace_id.clone(); let object_id = object_id.to_string(); let weak_cloud_service = Arc::downgrade(&self.cloud_service); Box::pin(async move { @@ -390,7 +397,7 @@ impl DatabaseCollabService for UserDatabaseCollabServiceImpl { }, Some(cloud_service) => { let updates = cloud_service - .get_collab_update(&object_id, object_ty) + .get_collab_update(&object_id, object_ty, &workspace_id) .await?; Ok(updates) }, @@ -403,6 +410,7 @@ impl DatabaseCollabService for UserDatabaseCollabServiceImpl { object_ids: Vec, object_ty: CollabType, ) -> CollabFuture> { + let workspace_id = self.workspace_id.clone(); let weak_cloud_service = Arc::downgrade(&self.cloud_service); Box::pin(async move { match weak_cloud_service.upgrade() { @@ -412,7 +420,7 @@ impl DatabaseCollabService for UserDatabaseCollabServiceImpl { }, Some(cloud_service) => { let updates = cloud_service - .batch_get_collab_updates(object_ids, object_ty) + .batch_get_collab_updates(object_ids, object_ty, &workspace_id) .await?; Ok(updates) }, diff --git a/frontend/rust-lib/flowy-document-deps/src/cloud.rs b/frontend/rust-lib/flowy-document-deps/src/cloud.rs index cd37ab706d..0a17113b7a 100644 --- a/frontend/rust-lib/flowy-document-deps/src/cloud.rs +++ b/frontend/rust-lib/flowy-document-deps/src/cloud.rs @@ -7,15 +7,24 @@ use lib_infra::future::FutureResult; /// Each kind of server should implement this trait. Check out the [AppFlowyServerProvider] of /// [flowy-server] crate for more information. pub trait DocumentCloudService: Send + Sync + 'static { - fn get_document_updates(&self, document_id: &str) -> FutureResult>, Error>; + fn get_document_updates( + &self, + document_id: &str, + workspace_id: &str, + ) -> FutureResult>, Error>; fn get_document_snapshots( &self, document_id: &str, limit: usize, + workspace_id: &str, ) -> FutureResult, Error>; - fn get_document_data(&self, document_id: &str) -> FutureResult, Error>; + fn get_document_data( + &self, + document_id: &str, + workspace_id: &str, + ) -> FutureResult, Error>; } pub struct DocumentSnapshot { diff --git a/frontend/rust-lib/flowy-document2/src/manager.rs b/frontend/rust-lib/flowy-document2/src/manager.rs index 0d001d45d6..2fe3dd829e 100644 --- a/frontend/rust-lib/flowy-document2/src/manager.rs +++ b/frontend/rust-lib/flowy-document2/src/manager.rs @@ -22,6 +22,9 @@ use crate::reminder::DocumentReminderAction; pub trait DocumentUser: Send + Sync { fn user_id(&self) -> Result; + + fn workspace_id(&self) -> Result; + fn token(&self) -> Result, FlowyError>; // unused now. fn collab_db(&self, uid: i64) -> Result, FlowyError>; } @@ -101,7 +104,10 @@ impl DocumentManager { let mut updates = vec![]; if !self.is_doc_exist(doc_id)? { // Try to get the document from the cloud service - updates = self.cloud_service.get_document_updates(doc_id).await?; + updates = self + .cloud_service + .get_document_updates(&self.user.workspace_id()?, doc_id) + .await?; } let uid = self.user.user_id()?; @@ -120,7 +126,10 @@ impl DocumentManager { pub async fn get_document_data(&self, doc_id: &str) -> FlowyResult { let mut updates = vec![]; if !self.is_doc_exist(doc_id)? { - updates = self.cloud_service.get_document_updates(doc_id).await?; + updates = self + .cloud_service + .get_document_updates(doc_id, &self.user.workspace_id()?) + .await?; } let uid = self.user.user_id()?; let collab = self.collab_for_document(uid, doc_id, updates).await?; @@ -152,9 +161,10 @@ impl DocumentManager { document_id: &str, limit: usize, ) -> FlowyResult> { + let workspace_id = self.user.workspace_id()?; let snapshots = self .cloud_service - .get_document_snapshots(document_id, limit) + .get_document_snapshots(document_id, limit, &workspace_id) .await? .into_iter() .map(|snapshot| DocumentSnapshotPB { diff --git a/frontend/rust-lib/flowy-document2/tests/document/util.rs b/frontend/rust-lib/flowy-document2/tests/document/util.rs index 70378775bc..4ee4fcb109 100644 --- a/frontend/rust-lib/flowy-document2/tests/document/util.rs +++ b/frontend/rust-lib/flowy-document2/tests/document/util.rs @@ -9,6 +9,7 @@ use nanoid::nanoid; use parking_lot::Once; use tempfile::TempDir; use tracing_subscriber::{fmt::Subscriber, util::SubscriberInitExt, EnvFilter}; +use uuid::Uuid; use collab_integrate::collab_builder::{AppFlowyCollabBuilder, DefaultCollabStorageProvider}; use collab_integrate::RocksCollabDB; @@ -61,6 +62,10 @@ impl DocumentUser for FakeUser { Ok(1) } + fn workspace_id(&self) -> Result { + Ok(Uuid::new_v4().to_string()) + } + fn token(&self) -> Result, FlowyError> { Ok(None) } @@ -120,7 +125,11 @@ pub fn gen_id() -> String { pub struct LocalTestDocumentCloudServiceImpl(); impl DocumentCloudService for LocalTestDocumentCloudServiceImpl { - fn get_document_updates(&self, _document_id: &str) -> FutureResult>, Error> { + fn get_document_updates( + &self, + _document_id: &str, + _workspace_id: &str, + ) -> FutureResult>, Error> { FutureResult::new(async move { Ok(vec![]) }) } @@ -128,11 +137,16 @@ impl DocumentCloudService for LocalTestDocumentCloudServiceImpl { &self, _document_id: &str, _limit: usize, + _workspace_id: &str, ) -> FutureResult, Error> { FutureResult::new(async move { Ok(vec![]) }) } - fn get_document_data(&self, _document_id: &str) -> FutureResult, Error> { + fn get_document_data( + &self, + _document_id: &str, + _workspace_id: &str, + ) -> FutureResult, Error> { FutureResult::new(async move { Ok(None) }) } } diff --git a/frontend/rust-lib/flowy-server/src/af_cloud/impls/database.rs b/frontend/rust-lib/flowy-server/src/af_cloud/impls/database.rs index 21d2b4af02..e5ec9038b4 100644 --- a/frontend/rust-lib/flowy-server/src/af_cloud/impls/database.rs +++ b/frontend/rust-lib/flowy-server/src/af_cloud/impls/database.rs @@ -1,6 +1,6 @@ use anyhow::Error; use client_api::entity::QueryCollabResult::{Failed, Success}; -use client_api::entity::{BatchQueryCollabParams, QueryCollabParams}; +use client_api::entity::{BatchQueryCollab, BatchQueryCollabParams, QueryCollabParams}; use client_api::error::ErrorCode::RecordNotFound; use collab_entity::CollabType; use tracing::error; @@ -22,11 +22,14 @@ where &self, object_id: &str, collab_type: CollabType, + workspace_id: &str, ) -> FutureResult { + let workspace_id = workspace_id.to_string(); let object_id = object_id.to_string(); let try_get_client = self.0.try_get_client(); FutureResult::new(async move { let params = QueryCollabParams { + workspace_id, object_id, collab_type, }; @@ -47,20 +50,22 @@ where &self, object_ids: Vec, object_ty: CollabType, + workspace_id: &str, ) -> FutureResult { + let workspace_id = workspace_id.to_string(); let try_get_client = self.0.try_get_client(); FutureResult::new(async move { let client = try_get_client?; let params = BatchQueryCollabParams( object_ids .into_iter() - .map(|object_id| QueryCollabParams { + .map(|object_id| BatchQueryCollab { object_id, collab_type: object_ty.clone(), }) .collect(), ); - let results = client.batch_get_collab(params).await?; + let results = client.batch_get_collab(&workspace_id, params).await?; Ok( results .0 diff --git a/frontend/rust-lib/flowy-server/src/af_cloud/impls/document.rs b/frontend/rust-lib/flowy-server/src/af_cloud/impls/document.rs index 91b2e193e8..2c46cebbae 100644 --- a/frontend/rust-lib/flowy-server/src/af_cloud/impls/document.rs +++ b/frontend/rust-lib/flowy-server/src/af_cloud/impls/document.rs @@ -16,11 +16,17 @@ impl DocumentCloudService for AFCloudDocumentCloudServiceImpl where T: AFServer, { - fn get_document_updates(&self, document_id: &str) -> FutureResult>, Error> { + fn get_document_updates( + &self, + document_id: &str, + workspace_id: &str, + ) -> FutureResult>, Error> { + let workspace_id = workspace_id.to_string(); let try_get_client = self.0.try_get_client(); let document_id = document_id.to_string(); FutureResult::new(async move { let params = QueryCollabParams { + workspace_id, object_id: document_id.to_string(), collab_type: CollabType::Document, }; @@ -36,15 +42,22 @@ where &self, _document_id: &str, _limit: usize, + _workspace_id: &str, ) -> FutureResult, Error> { FutureResult::new(async move { Ok(vec![]) }) } - fn get_document_data(&self, document_id: &str) -> FutureResult, Error> { + fn get_document_data( + &self, + document_id: &str, + workspace_id: &str, + ) -> FutureResult, Error> { let try_get_client = self.0.try_get_client(); let document_id = document_id.to_string(); + let workspace_id = workspace_id.to_string(); FutureResult::new(async move { let params = QueryCollabParams { + workspace_id, object_id: document_id.clone(), collab_type: CollabType::Document, }; diff --git a/frontend/rust-lib/flowy-server/src/af_cloud/impls/file_storage.rs b/frontend/rust-lib/flowy-server/src/af_cloud/impls/file_storage.rs index 507a26eabb..569ad3877b 100644 --- a/frontend/rust-lib/flowy-server/src/af_cloud/impls/file_storage.rs +++ b/frontend/rust-lib/flowy-server/src/af_cloud/impls/file_storage.rs @@ -33,10 +33,10 @@ where .to_string(); let mut buffer = Vec::new(); file.read_to_end(&mut buffer).await?; - Ok(client.put_file(&object.workspace_id, buffer, mime).await?) + Ok(client.put_blob(&object.workspace_id, buffer, mime).await?) }, ObjectValue::Bytes { bytes, mime } => { - Ok(client.put_file(&object.workspace_id, bytes, mime).await?) + Ok(client.put_blob(&object.workspace_id, bytes, mime).await?) }, } }) @@ -46,7 +46,7 @@ where let try_get_client = self.0.try_get_client(); FutureResult::new(async move { let client = try_get_client?; - client.delete_file(&object_url).await?; + client.delete_blob(&object_url).await?; Ok(()) }) } @@ -55,7 +55,7 @@ where let try_get_client = self.0.try_get_client(); FutureResult::new(async move { let client = try_get_client?; - let bytes = client.get_file(&object_url).await?; + let bytes = client.get_blob(&object_url).await?; Ok(bytes) }) } diff --git a/frontend/rust-lib/flowy-server/src/af_cloud/impls/folder.rs b/frontend/rust-lib/flowy-server/src/af_cloud/impls/folder.rs index 210b40b611..0f4d6283a6 100644 --- a/frontend/rust-lib/flowy-server/src/af_cloud/impls/folder.rs +++ b/frontend/rust-lib/flowy-server/src/af_cloud/impls/folder.rs @@ -25,6 +25,7 @@ where FutureResult::new(async move { let params = QueryCollabParams { object_id: workspace_id.clone(), + workspace_id: workspace_id.clone(), collab_type: CollabType::Folder, }; let updates = vec![try_get_client? @@ -50,7 +51,8 @@ where let try_get_client = self.0.try_get_client(); FutureResult::new(async move { let params = QueryCollabParams { - object_id: workspace_id, + object_id: workspace_id.clone(), + workspace_id, collab_type: CollabType::Folder, }; let update = try_get_client? diff --git a/frontend/rust-lib/flowy-server/src/af_cloud/impls/user.rs b/frontend/rust-lib/flowy-server/src/af_cloud/impls/user.rs index f31d269ba2..bd8419d93f 100644 --- a/frontend/rust-lib/flowy-server/src/af_cloud/impls/user.rs +++ b/frontend/rust-lib/flowy-server/src/af_cloud/impls/user.rs @@ -2,9 +2,10 @@ use std::collections::HashMap; use std::sync::Arc; use anyhow::{anyhow, Error}; -use client_api::entity::dto::UserUpdateParams; +use client_api::entity::dto::auth_dto::UpdateUsernameParams; +use client_api::entity::dto::workspace_dto::CreateWorkspaceMember; use client_api::entity::{ - AFUserProfileView, AFWorkspace, AFWorkspaces, InsertCollabParams, OAuthProvider, + AFRole, AFUserProfileView, AFWorkspace, AFWorkspaces, InsertCollabParams, OAuthProvider, }; use collab_entity::CollabObject; @@ -91,10 +92,11 @@ where FutureResult::new(async move { let client = try_get_client?; client - .update(UserUpdateParams { + .update_user(UpdateUsernameParams { name: params.name, email: params.email, password: params.password, + metadata: None, }) .await?; Ok(()) @@ -108,7 +110,7 @@ where let try_get_client = self.server.try_get_client(); FutureResult::new(async move { let client = try_get_client?; - let profile = client.profile().await?; + let profile = client.get_profile().await?; let encryption_type = encryption_type_from_profile(&profile); Ok(Some(UserProfile { email: profile.email.unwrap_or("".to_string()), @@ -131,7 +133,7 @@ where fn get_user_workspaces(&self, _uid: i64) -> FutureResult, Error> { let try_get_client = self.server.try_get_client(); FutureResult::new(async move { - let workspaces = try_get_client?.workspaces().await?; + let workspaces = try_get_client?.get_workspaces().await?; Ok(to_user_workspaces(workspaces)?) }) } @@ -145,7 +147,7 @@ where // from cloud let client = try_get_client?; - let profile = client.profile().await?; + let profile = client.get_profile().await?; let client_token = client.access_token()?; // compare and check @@ -167,7 +169,13 @@ where let try_get_client = self.server.try_get_client(); FutureResult::new(async move { try_get_client? - .add_workspace_members(workspace_id.parse()?, vec![user_email]) + .add_workspace_members( + workspace_id, + vec![CreateWorkspaceMember { + email: user_email, + role: AFRole::Member, + }], + ) .await?; Ok(()) }) @@ -181,7 +189,7 @@ where let try_get_client = self.server.try_get_client(); FutureResult::new(async move { try_get_client? - .remove_workspace_members(workspace_id.parse()?, vec![user_email]) + .remove_workspace_members(workspace_id, vec![user_email]) .await?; Ok(()) }) @@ -230,7 +238,7 @@ pub async fn user_sign_in_with_url( params: AFCloudOAuthParams, ) -> Result { let is_new_user = client.sign_in_with_url(¶ms.sign_in_url).await?; - let (profile, af_workspaces) = tokio::try_join!(client.profile(), client.workspaces())?; + let (profile, af_workspaces) = tokio::try_join!(client.get_profile(), client.get_workspaces())?; let latest_workspace = to_user_workspace( af_workspaces diff --git a/frontend/rust-lib/flowy-server/src/local_server/impls/database.rs b/frontend/rust-lib/flowy-server/src/local_server/impls/database.rs index f004912384..cec38613bf 100644 --- a/frontend/rust-lib/flowy-server/src/local_server/impls/database.rs +++ b/frontend/rust-lib/flowy-server/src/local_server/impls/database.rs @@ -13,6 +13,7 @@ impl DatabaseCloudService for LocalServerDatabaseCloudServiceImpl { &self, _object_id: &str, _collab_type: CollabType, + _workspace_id: &str, ) -> FutureResult { FutureResult::new(async move { Ok(vec![]) }) } @@ -21,6 +22,7 @@ impl DatabaseCloudService for LocalServerDatabaseCloudServiceImpl { &self, _object_ids: Vec, _object_ty: CollabType, + _workspace_id: &str, ) -> FutureResult { FutureResult::new(async move { Ok(CollabObjectUpdateByOid::default()) }) } diff --git a/frontend/rust-lib/flowy-server/src/local_server/impls/document.rs b/frontend/rust-lib/flowy-server/src/local_server/impls/document.rs index 71e1481a28..6797270a00 100644 --- a/frontend/rust-lib/flowy-server/src/local_server/impls/document.rs +++ b/frontend/rust-lib/flowy-server/src/local_server/impls/document.rs @@ -6,7 +6,11 @@ use lib_infra::future::FutureResult; pub(crate) struct LocalServerDocumentCloudServiceImpl(); impl DocumentCloudService for LocalServerDocumentCloudServiceImpl { - fn get_document_updates(&self, _document_id: &str) -> FutureResult>, Error> { + fn get_document_updates( + &self, + _document_id: &str, + _workspace_id: &str, + ) -> FutureResult>, Error> { FutureResult::new(async move { Ok(vec![]) }) } @@ -14,11 +18,16 @@ impl DocumentCloudService for LocalServerDocumentCloudServiceImpl { &self, _document_id: &str, _limit: usize, + _workspace_id: &str, ) -> FutureResult, Error> { FutureResult::new(async move { Ok(vec![]) }) } - fn get_document_data(&self, _document_id: &str) -> FutureResult, Error> { + fn get_document_data( + &self, + _document_id: &str, + _workspace_id: &str, + ) -> FutureResult, Error> { FutureResult::new(async move { Ok(None) }) } } diff --git a/frontend/rust-lib/flowy-server/src/supabase/api/database.rs b/frontend/rust-lib/flowy-server/src/supabase/api/database.rs index cc2e6b6640..963978c2fc 100644 --- a/frontend/rust-lib/flowy-server/src/supabase/api/database.rs +++ b/frontend/rust-lib/flowy-server/src/supabase/api/database.rs @@ -30,6 +30,7 @@ where &self, object_id: &str, collab_type: CollabType, + _workspace_id: &str, ) -> FutureResult { let try_get_postgrest = self.server.try_get_weak_postgrest(); let object_id = object_id.to_string(); @@ -53,6 +54,7 @@ where &self, object_ids: Vec, object_ty: CollabType, + _workspace_id: &str, ) -> FutureResult { let try_get_postgrest = self.server.try_get_weak_postgrest(); let (tx, rx) = channel(); diff --git a/frontend/rust-lib/flowy-server/src/supabase/api/document.rs b/frontend/rust-lib/flowy-server/src/supabase/api/document.rs index 48987fcead..9968a1c44b 100644 --- a/frontend/rust-lib/flowy-server/src/supabase/api/document.rs +++ b/frontend/rust-lib/flowy-server/src/supabase/api/document.rs @@ -27,7 +27,11 @@ where T: SupabaseServerService, { #[tracing::instrument(level = "debug", skip(self))] - fn get_document_updates(&self, document_id: &str) -> FutureResult>, Error> { + fn get_document_updates( + &self, + document_id: &str, + workspace_id: &str, + ) -> FutureResult>, Error> { let try_get_postgrest = self.server.try_get_weak_postgrest(); let document_id = document_id.to_string(); let (tx, rx) = channel(); @@ -52,6 +56,7 @@ where &self, document_id: &str, limit: usize, + _workspace_id: &str, ) -> FutureResult, Error> { let try_get_postgrest = self.server.try_get_postgrest(); let document_id = document_id.to_string(); @@ -72,7 +77,11 @@ where } #[tracing::instrument(level = "debug", skip(self))] - fn get_document_data(&self, document_id: &str) -> FutureResult, Error> { + fn get_document_data( + &self, + document_id: &str, + workspace_id: &str, + ) -> FutureResult, Error> { let try_get_postgrest = self.server.try_get_weak_postgrest(); let document_id = document_id.to_string(); let (tx, rx) = channel(); diff --git a/frontend/rust-lib/flowy-server/tests/supabase_test/database_test.rs b/frontend/rust-lib/flowy-server/tests/supabase_test/database_test.rs index 6521c870ea..9f638bb226 100644 --- a/frontend/rust-lib/flowy-server/tests/supabase_test/database_test.rs +++ b/frontend/rust-lib/flowy-server/tests/supabase_test/database_test.rs @@ -45,7 +45,7 @@ async fn supabase_create_database_test() { } let updates_by_oid = database_service - .batch_get_collab_updates(row_ids, CollabType::DatabaseRow) + .batch_get_collab_updates(row_ids, CollabType::DatabaseRow, "fake_workspace_id") .await .unwrap(); diff --git a/frontend/rust-lib/flowy-user/src/manager.rs b/frontend/rust-lib/flowy-user/src/manager.rs index a89c77ecec..6610583e7a 100644 --- a/frontend/rust-lib/flowy-user/src/manager.rs +++ b/frontend/rust-lib/flowy-user/src/manager.rs @@ -5,7 +5,7 @@ use collab_user::core::MutexUserAwareness; use serde_json::Value; use tokio::sync::{Mutex, RwLock}; use tokio_stream::StreamExt; -use tracing::{debug, error, info, instrument}; +use tracing::{debug, error, event, info, instrument}; use collab_integrate::collab_builder::AppFlowyCollabBuilder; use collab_integrate::RocksCollabDB; @@ -347,16 +347,18 @@ impl UserManager { UserAwarenessDataSource::Remote }; - debug!("Sign up response: {:?}", response); + event!(tracing::Level::DEBUG, "Sign up response: {:?}", response); if response.is_new_user { if let Some(old_user) = migration_user { let new_user = MigrationUser { user_profile: user_profile.clone(), session: new_session.clone(), }; - info!( + event!( + tracing::Level::INFO, "Migrate old user data from {:?} to {:?}", - old_user.user_profile.uid, new_user.user_profile.uid + old_user.user_profile.uid, + new_user.user_profile.uid ); self .migrate_local_user_to_cloud(&old_user, &new_user) @@ -488,6 +490,10 @@ impl UserManager { Ok(self.get_session()?.user_id) } + pub fn workspace_id(&self) -> Result { + Ok(self.get_session()?.user_workspace.id) + } + pub fn token(&self) -> Result, FlowyError> { Ok(None) }