From cbcf43081f77a5a053325ab0520d517086b7d412 Mon Sep 17 00:00:00 2001 From: "Nathan.fooo" <86001920+appflowy@users.noreply.github.com> Date: Wed, 21 Feb 2024 09:47:38 +0800 Subject: [PATCH] chore: add disable collab ac feature flag (#336) --- Cargo.toml | 2 ++ Dockerfile | 3 ++- src/biz/casbin/collab_ac.rs | 24 ++++++++++++++++-------- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 06ac4729..d298353f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -179,6 +179,8 @@ collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev [features] custom_env= [] +# This feature will be removed once the cpu spike issue is resolved +disable_collab_ac = [] # Comment the above and uncomment the below to use local version of collab by cloning the repo and placing it in libs folder #collab = { path = "libs/AppFlowy-Collab/collab" } diff --git a/Dockerfile b/Dockerfile index caab48d5..6ee581f5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,7 +16,8 @@ COPY . . ENV SQLX_OFFLINE true # Build the project -RUN cargo build --profile=profiling --bin appflowy_cloud +RUN cargo build --profile=profiling --features="disable_collab_ac" --bin appflowy_cloud + FROM debian:bookworm-slim AS runtime WORKDIR /app diff --git a/src/biz/casbin/collab_ac.rs b/src/biz/casbin/collab_ac.rs index 8ef76a9e..cf703e4b 100644 --- a/src/biz/casbin/collab_ac.rs +++ b/src/biz/casbin/collab_ac.rs @@ -81,16 +81,24 @@ impl CollabAccessControl for CollabAccessControlImpl { } async fn can_send_collab_update(&self, uid: &i64, oid: &str) -> Result { - self - .access_control - .enforce(uid, &ObjectType::Collab(oid), Action::Write) - .await + if cfg!(feature = "disable_collab_ac") { + Ok(true) + } else { + self + .access_control + .enforce(uid, &ObjectType::Collab(oid), Action::Write) + .await + } } async fn can_receive_collab_update(&self, uid: &i64, oid: &str) -> Result { - self - .access_control - .enforce(uid, &ObjectType::Collab(oid), Action::Read) - .await + if cfg!(feature = "disable_collab_ac") { + Ok(true) + } else { + self + .access_control + .enforce(uid, &ObjectType::Collab(oid), Action::Read) + .await + } } }