Merge branch 'main' into feat/workspace-invite-fields

This commit is contained in:
Zack Fu Zi Xiang 2024-09-15 13:59:25 +08:00
commit 35786fb2d5
No known key found for this signature in database
8 changed files with 31 additions and 22 deletions

13
Cargo.lock generated
View File

@ -2092,7 +2092,7 @@ dependencies = [
[[package]] [[package]]
name = "collab" name = "collab"
version = "0.2.0" 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 = [ dependencies = [
"anyhow", "anyhow",
"arc-swap", "arc-swap",
@ -2117,7 +2117,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-database" name = "collab-database"
version = "0.2.0" 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 = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@ -2147,7 +2147,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-document" name = "collab-document"
version = "0.2.0" 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 = [ dependencies = [
"anyhow", "anyhow",
"arc-swap", "arc-swap",
@ -2167,7 +2167,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-entity" name = "collab-entity"
version = "0.2.0" 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 = [ dependencies = [
"anyhow", "anyhow",
"bytes", "bytes",
@ -2179,6 +2179,7 @@ dependencies = [
"serde", "serde",
"serde_json", "serde_json",
"serde_repr", "serde_repr",
"thiserror",
"uuid", "uuid",
"walkdir", "walkdir",
] ]
@ -2186,7 +2187,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-folder" name = "collab-folder"
version = "0.2.0" 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 = [ dependencies = [
"anyhow", "anyhow",
"arc-swap", "arc-swap",
@ -2271,7 +2272,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-user" name = "collab-user"
version = "0.2.0" 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 = [ dependencies = [
"anyhow", "anyhow",
"collab", "collab",

View File

@ -288,12 +288,12 @@ debug = true
[patch.crates-io] [patch.crates-io]
# It's diffcult to resovle different version with the same crate used in AppFlowy Frontend and the Client-API crate. # 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. # So using patch to workaround this issue.
collab = { 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 = "71c5bd32ddb72252e8f8eddfd4f5ce75ecd31354" } collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ca26f6f4d205834ce1eb7291003d6f869ef66dc6" }
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "71c5bd32ddb72252e8f8eddfd4f5ce75ecd31354" } collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ca26f6f4d205834ce1eb7291003d6f869ef66dc6" }
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "71c5bd32ddb72252e8f8eddfd4f5ce75ecd31354" } collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ca26f6f4d205834ce1eb7291003d6f869ef66dc6" }
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "71c5bd32ddb72252e8f8eddfd4f5ce75ecd31354" } collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ca26f6f4d205834ce1eb7291003d6f869ef66dc6" }
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "71c5bd32ddb72252e8f8eddfd4f5ce75ecd31354" } collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ca26f6f4d205834ce1eb7291003d6f869ef66dc6" }
[features] [features]
history = [] history = []

View File

@ -191,7 +191,7 @@ where
Sink: SinkExt<Vec<ClientCollabMessage>, Error = E> + Send + Sync + Unpin + 'static, Sink: SinkExt<Vec<ClientCollabMessage>, Error = E> + Send + Sync + Unpin + 'static,
{ {
if let Err(err) = sync_object.collab_type.validate_require_data(collab) { 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 { match reason {

View File

@ -3,7 +3,7 @@
# Generate the current dependency list # Generate the current dependency list
cargo tree > current_deps.txt cargo tree > current_deps.txt
BASELINE_COUNT=619 BASELINE_COUNT=620
CURRENT_COUNT=$(cat current_deps.txt | wc -l) CURRENT_COUNT=$(cat current_deps.txt | wc -l)
echo "Expected dependency count (baseline): $BASELINE_COUNT" echo "Expected dependency count (baseline): $BASELINE_COUNT"

View File

@ -120,8 +120,12 @@ impl CollabGroup {
pub async fn encode_collab(&self) -> Result<EncodedCollab, RealtimeError> { pub async fn encode_collab(&self) -> Result<EncodedCollab, RealtimeError> {
let lock = self.collab.read().await; let lock = self.collab.read().await;
let encode_collab = let encode_collab = lock.encode_collab_v1(|collab| {
lock.encode_collab_v1(|collab| self.collab_type.validate_require_data(collab))?; self
.collab_type
.validate_require_data(collab)
.map_err(|err| RealtimeError::Internal(err.into()))
})?;
Ok(encode_collab) Ok(encode_collab)
} }

View File

@ -74,8 +74,12 @@ impl OpenCollabHandle {
pub async fn history_state(&self) -> Result<HistoryStatePb, HistoryError> { pub async fn history_state(&self) -> Result<HistoryStatePb, HistoryError> {
let lock_guard = self.collab.read().await; let lock_guard = self.collab.read().await;
let encode_collab = let encode_collab = lock_guard.encode_collab_v1(|collab| {
lock_guard.encode_collab_v1(|collab| self.collab_type.validate_require_data(collab))?; self
.collab_type
.validate_require_data(collab)
.map_err(|err| HistoryError::Internal(err.into()))
})?;
Ok(HistoryStatePb { Ok(HistoryStatePb {
object_id: self.object_id.clone(), object_id: self.object_id.clone(),
doc_state: encode_collab.doc_state.to_vec(), doc_state: encode_collab.doc_state.to_vec(),

View File

@ -196,8 +196,8 @@ pub fn workspace_scope() -> Scope {
) )
.service( .service(
web::resource("/{workspace_id}/collab_list") web::resource("/{workspace_id}/collab_list")
.route(web::get().to(batch_get_collab_handler)) // deprecated: browser cannot use json param .route(web::get().to(batch_get_collab_handler))
// for GET request // 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)), .route(web::post().to(batch_get_collab_handler)),
) )
} }

View File

@ -126,7 +126,7 @@ async fn create_user_awareness(
let user_awareness = UserAwareness::create(collab, None)?; let user_awareness = UserAwareness::create(collab, None)?;
let encode_collab = user_awareness let encode_collab = user_awareness
.encode_collab_v1(|collab| collab_type.validate_require_data(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 let encoded_collab_v1 = encode_collab
.encode_to_bytes() .encode_to_bytes()
.map_err(|err| AppError::Internal(anyhow::Error::from(err)))?; .map_err(|err| AppError::Internal(anyhow::Error::from(err)))?;
@ -167,7 +167,7 @@ async fn create_workspace_database_collab(
let encode_collab = collab let encode_collab = collab
.encode_collab_v1(|collab| collab_type.validate_require_data(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 let encoded_collab_v1 = encode_collab
.encode_to_bytes() .encode_to_bytes()