From 4c54481d704bf2f1b5118b4f36add7fb953c0cfc Mon Sep 17 00:00:00 2001 From: "Nathan.fooo" <86001920+appflowy@users.noreply.github.com> Date: Sat, 14 Sep 2024 23:59:50 +0800 Subject: [PATCH] chore: bump collab version (#822) * chore: bump collab version * chore: update deps count --- Cargo.lock | 13 +++++++------ Cargo.toml | 12 ++++++------ libs/client-api/src/collab_sync/sync_control.rs | 2 +- script/client_api_deps_check.sh | 2 +- .../appflowy-collaborate/src/group/group_init.rs | 8 ++++++-- services/appflowy-history/src/core/open_handle.rs | 8 ++++++-- src/api/workspace.rs | 4 ++-- src/biz/user/user_init.rs | 4 ++-- 8 files changed, 31 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 114653ac..369e62ae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2092,7 +2092,7 @@ dependencies = [ [[package]] name = "collab" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=71c5bd32ddb72252e8f8eddfd4f5ce75ecd31354#71c5bd32ddb72252e8f8eddfd4f5ce75ecd31354" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ca26f6f4d205834ce1eb7291003d6f869ef66dc6#ca26f6f4d205834ce1eb7291003d6f869ef66dc6" dependencies = [ "anyhow", "arc-swap", @@ -2117,7 +2117,7 @@ dependencies = [ [[package]] name = "collab-database" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=71c5bd32ddb72252e8f8eddfd4f5ce75ecd31354#71c5bd32ddb72252e8f8eddfd4f5ce75ecd31354" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ca26f6f4d205834ce1eb7291003d6f869ef66dc6#ca26f6f4d205834ce1eb7291003d6f869ef66dc6" dependencies = [ "anyhow", "async-trait", @@ -2147,7 +2147,7 @@ dependencies = [ [[package]] name = "collab-document" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=71c5bd32ddb72252e8f8eddfd4f5ce75ecd31354#71c5bd32ddb72252e8f8eddfd4f5ce75ecd31354" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ca26f6f4d205834ce1eb7291003d6f869ef66dc6#ca26f6f4d205834ce1eb7291003d6f869ef66dc6" dependencies = [ "anyhow", "arc-swap", @@ -2167,7 +2167,7 @@ dependencies = [ [[package]] name = "collab-entity" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=71c5bd32ddb72252e8f8eddfd4f5ce75ecd31354#71c5bd32ddb72252e8f8eddfd4f5ce75ecd31354" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ca26f6f4d205834ce1eb7291003d6f869ef66dc6#ca26f6f4d205834ce1eb7291003d6f869ef66dc6" dependencies = [ "anyhow", "bytes", @@ -2179,6 +2179,7 @@ dependencies = [ "serde", "serde_json", "serde_repr", + "thiserror", "uuid", "walkdir", ] @@ -2186,7 +2187,7 @@ dependencies = [ [[package]] name = "collab-folder" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=71c5bd32ddb72252e8f8eddfd4f5ce75ecd31354#71c5bd32ddb72252e8f8eddfd4f5ce75ecd31354" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ca26f6f4d205834ce1eb7291003d6f869ef66dc6#ca26f6f4d205834ce1eb7291003d6f869ef66dc6" dependencies = [ "anyhow", "arc-swap", @@ -2271,7 +2272,7 @@ dependencies = [ [[package]] name = "collab-user" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=71c5bd32ddb72252e8f8eddfd4f5ce75ecd31354#71c5bd32ddb72252e8f8eddfd4f5ce75ecd31354" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ca26f6f4d205834ce1eb7291003d6f869ef66dc6#ca26f6f4d205834ce1eb7291003d6f869ef66dc6" dependencies = [ "anyhow", "collab", diff --git a/Cargo.toml b/Cargo.toml index 00f3d66d..d4a001fc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -288,12 +288,12 @@ debug = true [patch.crates-io] # It's diffcult to resovle different version with the same crate used in AppFlowy Frontend and the Client-API crate. # So using patch to workaround this issue. -collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "71c5bd32ddb72252e8f8eddfd4f5ce75ecd31354" } -collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "71c5bd32ddb72252e8f8eddfd4f5ce75ecd31354" } -collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "71c5bd32ddb72252e8f8eddfd4f5ce75ecd31354" } -collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "71c5bd32ddb72252e8f8eddfd4f5ce75ecd31354" } -collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "71c5bd32ddb72252e8f8eddfd4f5ce75ecd31354" } -collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "71c5bd32ddb72252e8f8eddfd4f5ce75ecd31354" } +collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ca26f6f4d205834ce1eb7291003d6f869ef66dc6" } +collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ca26f6f4d205834ce1eb7291003d6f869ef66dc6" } +collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ca26f6f4d205834ce1eb7291003d6f869ef66dc6" } +collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ca26f6f4d205834ce1eb7291003d6f869ef66dc6" } +collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ca26f6f4d205834ce1eb7291003d6f869ef66dc6" } +collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ca26f6f4d205834ce1eb7291003d6f869ef66dc6" } [features] history = [] diff --git a/libs/client-api/src/collab_sync/sync_control.rs b/libs/client-api/src/collab_sync/sync_control.rs index 909d59f6..99437da0 100644 --- a/libs/client-api/src/collab_sync/sync_control.rs +++ b/libs/client-api/src/collab_sync/sync_control.rs @@ -191,7 +191,7 @@ where Sink: SinkExt, Error = E> + Send + Sync + Unpin + 'static, { if let Err(err) = sync_object.collab_type.validate_require_data(collab) { - return Err(SyncError::Internal(err)); + return Err(SyncError::Internal(err.into())); } match reason { diff --git a/script/client_api_deps_check.sh b/script/client_api_deps_check.sh index 6c947187..3e831065 100755 --- a/script/client_api_deps_check.sh +++ b/script/client_api_deps_check.sh @@ -3,7 +3,7 @@ # Generate the current dependency list cargo tree > current_deps.txt -BASELINE_COUNT=619 +BASELINE_COUNT=620 CURRENT_COUNT=$(cat current_deps.txt | wc -l) echo "Expected dependency count (baseline): $BASELINE_COUNT" diff --git a/services/appflowy-collaborate/src/group/group_init.rs b/services/appflowy-collaborate/src/group/group_init.rs index 5c316a1b..04a3aeea 100644 --- a/services/appflowy-collaborate/src/group/group_init.rs +++ b/services/appflowy-collaborate/src/group/group_init.rs @@ -120,8 +120,12 @@ impl CollabGroup { pub async fn encode_collab(&self) -> Result { let lock = self.collab.read().await; - let encode_collab = - lock.encode_collab_v1(|collab| self.collab_type.validate_require_data(collab))?; + let encode_collab = lock.encode_collab_v1(|collab| { + self + .collab_type + .validate_require_data(collab) + .map_err(|err| RealtimeError::Internal(err.into())) + })?; Ok(encode_collab) } diff --git a/services/appflowy-history/src/core/open_handle.rs b/services/appflowy-history/src/core/open_handle.rs index f8573561..168e864c 100644 --- a/services/appflowy-history/src/core/open_handle.rs +++ b/services/appflowy-history/src/core/open_handle.rs @@ -74,8 +74,12 @@ impl OpenCollabHandle { pub async fn history_state(&self) -> Result { let lock_guard = self.collab.read().await; - let encode_collab = - lock_guard.encode_collab_v1(|collab| self.collab_type.validate_require_data(collab))?; + let encode_collab = lock_guard.encode_collab_v1(|collab| { + self + .collab_type + .validate_require_data(collab) + .map_err(|err| HistoryError::Internal(err.into())) + })?; Ok(HistoryStatePb { object_id: self.object_id.clone(), doc_state: encode_collab.doc_state.to_vec(), diff --git a/src/api/workspace.rs b/src/api/workspace.rs index 713d584f..3c2807f6 100644 --- a/src/api/workspace.rs +++ b/src/api/workspace.rs @@ -195,8 +195,8 @@ pub fn workspace_scope() -> Scope { ) .service( web::resource("/{workspace_id}/collab_list") - .route(web::get().to(batch_get_collab_handler)) // deprecated: browser cannot use json param - // for GET request + .route(web::get().to(batch_get_collab_handler)) + // Web browser can't carry payload when using GET method, so for browser compatibility, we use POST method .route(web::post().to(batch_get_collab_handler)), ) } diff --git a/src/biz/user/user_init.rs b/src/biz/user/user_init.rs index a8f83651..135ebd13 100644 --- a/src/biz/user/user_init.rs +++ b/src/biz/user/user_init.rs @@ -126,7 +126,7 @@ async fn create_user_awareness( let user_awareness = UserAwareness::create(collab, None)?; let encode_collab = user_awareness .encode_collab_v1(|collab| collab_type.validate_require_data(collab)) - .map_err(AppError::Internal)?; + .map_err(|err| AppError::Internal(err.into()))?; let encoded_collab_v1 = encode_collab .encode_to_bytes() .map_err(|err| AppError::Internal(anyhow::Error::from(err)))?; @@ -167,7 +167,7 @@ async fn create_workspace_database_collab( let encode_collab = collab .encode_collab_v1(|collab| collab_type.validate_require_data(collab)) - .map_err(AppError::Internal)?; + .map_err(|err| AppError::Internal(err.into()))?; let encoded_collab_v1 = encode_collab .encode_to_bytes()