From ee31a680b5789b8c7c5397e6eadd4dd7739526f9 Mon Sep 17 00:00:00 2001 From: "Nathan.fooo" <86001920+appflowy@users.noreply.github.com> Date: Tue, 5 Dec 2023 22:21:11 -0800 Subject: [PATCH] chore: unlimited json payload size (#197) * chore: return ok when token is empty * chore: remove json payload size limit * chore: clippy --- libs/client-api/src/http.rs | 4 ++++ libs/client-api/src/notify.rs | 4 ++++ src/api/workspace.rs | 2 +- src/application.rs | 3 +-- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/libs/client-api/src/http.rs b/libs/client-api/src/http.rs index 1c4e0b0a..f739c852 100644 --- a/libs/client-api/src/http.rs +++ b/libs/client-api/src/http.rs @@ -668,6 +668,10 @@ impl Client { #[instrument(level = "debug", skip_all, err)] pub async fn sign_out(&self) -> Result<(), AppResponseError> { + if self.token.read().is_empty() { + return Ok(()); + } + self.gotrue_client.logout(&self.access_token()?).await?; self.token.write().unset(); Ok(()) diff --git a/libs/client-api/src/notify.rs b/libs/client-api/src/notify.rs index 2f634d0d..06394b64 100644 --- a/libs/client-api/src/notify.rs +++ b/libs/client-api/src/notify.rs @@ -26,6 +26,10 @@ impl ClientToken { } } + pub fn is_empty(&self) -> bool { + self.token.is_none() + } + pub fn try_get(&self) -> Result { match &self.token { None => Err(anyhow::anyhow!("No access token")), diff --git a/src/api/workspace.rs b/src/api/workspace.rs index 171fffcb..43491193 100644 --- a/src/api/workspace.rs +++ b/src/api/workspace.rs @@ -43,7 +43,7 @@ pub fn workspace_scope() -> Scope { .service( web::resource("{workspace_id}/collab/{object_id}") .app_data( - PayloadConfig::new(5 * 1024 * 1024), // 10 MB + PayloadConfig::new(5 * 1024 * 1024), // 5 MB ) .route(web::post().to(create_collab_handler)) .route(web::get().to(get_collab_handler)) diff --git a/src/application.rs b/src/application.rs index 13306b92..f0c0c1f6 100644 --- a/src/application.rs +++ b/src/application.rs @@ -9,7 +9,7 @@ use actix_identity::IdentityMiddleware; use actix_session::storage::RedisSessionStore; use actix_session::SessionMiddleware; use actix_web::cookie::Key; -use actix_web::{dev::Server, web, web::Data, App, HttpServer}; +use actix_web::{dev::Server, web::Data, App, HttpServer}; use actix::Actor; use anyhow::{Context, Error}; @@ -119,7 +119,6 @@ pub async fn run( // .wrap(DecryptPayloadMiddleware) .wrap(RequestIdMiddleware) .wrap(access_control.clone()) - .app_data(web::JsonConfig::default().limit(4096)) .service(user_scope()) .service(workspace_scope()) .service(collab_scope())