Skip to content

Commit

Permalink
chore: unlimited json payload size (AppFlowy-IO#197)
Browse files Browse the repository at this point in the history
* chore: return ok when token is empty

* chore: remove json payload size limit

* chore: clippy
  • Loading branch information
appflowy authored Dec 6, 2023
1 parent f13a03b commit ee31a68
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions libs/client-api/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand Down
4 changes: 4 additions & 0 deletions libs/client-api/src/notify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ impl ClientToken {
}
}

pub fn is_empty(&self) -> bool {
self.token.is_none()
}

pub fn try_get(&self) -> Result<String, Error> {
match &self.token {
None => Err(anyhow::anyhow!("No access token")),
Expand Down
2 changes: 1 addition & 1 deletion src/api/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
3 changes: 1 addition & 2 deletions src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit ee31a68

Please sign in to comment.