From 048e2645ba5ba98b53a54b7fc6a30064be313ffe Mon Sep 17 00:00:00 2001 From: Zack Fu Zi Xiang Date: Mon, 1 Jul 2024 16:57:48 +0800 Subject: [PATCH] chore: longer publish name limit --- src/biz/workspace/ops.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/biz/workspace/ops.rs b/src/biz/workspace/ops.rs index 7fa8de16..5aba8906 100644 --- a/src/biz/workspace/ops.rs +++ b/src/biz/workspace/ops.rs @@ -561,6 +561,12 @@ async fn check_workspace_namespace(new_namespace: &str) -> Result<(), AppError> )); } + if new_namespace.len() > 32 { + return Err(AppError::InvalidRequest( + "Namespace must be at most 32 characters long".to_string(), + )); + } + // Only contain alphanumeric characters and hyphens for c in new_namespace.chars() { if !c.is_alphanumeric() && c != '-' { @@ -570,6 +576,8 @@ async fn check_workspace_namespace(new_namespace: &str) -> Result<(), AppError> } } + // TODO: add more checks for reserved words + Ok(()) } @@ -595,9 +603,9 @@ async fn check_workspace_owner_or_publisher( fn check_collab_publish_name(publish_name: &str) -> Result<(), AppError> { // Check len - if publish_name.len() > 50 { + if publish_name.len() > 128 { return Err(AppError::InvalidRequest( - "Document name must be at most 50 characters long".to_string(), + "Publish name must be at most 128 characters long".to_string(), )); } @@ -605,7 +613,7 @@ fn check_collab_publish_name(publish_name: &str) -> Result<(), AppError> { for c in publish_name.chars() { if !c.is_alphanumeric() && c != '-' { return Err(AppError::InvalidRequest( - "Document name must only contain alphanumeric characters and hyphens".to_string(), + "Publish name must only contain alphanumeric characters and hyphens".to_string(), )); } }