chore: add disable collab ac feature flag (#336)

This commit is contained in:
Nathan.fooo 2024-02-21 09:47:38 +08:00 committed by GitHub
parent 399f7ba2b5
commit cbcf43081f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 20 additions and 9 deletions

View File

@ -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" }

View File

@ -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

View File

@ -81,16 +81,24 @@ impl CollabAccessControl for CollabAccessControlImpl {
}
async fn can_send_collab_update(&self, uid: &i64, oid: &str) -> Result<bool, AppError> {
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<bool, AppError> {
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
}
}
}