diff --git a/crates/app/src/public/html/communities/create_post.lisp b/crates/app/src/public/html/communities/create_post.lisp index 3d1b965..454a868 100644 --- a/crates/app/src/public/html/communities/create_post.lisp +++ b/crates/app/src/public/html/communities/create_post.lisp @@ -473,14 +473,19 @@ } setTimeout(() => { - update_community_avatar({ - target: document.getElementById(\"community_to_post_to\"), - }); + const fake_select = { + parentElement: document.getElementById(\"community_to_post_to\").parentElement, + selectedOptions: [{ + value: \"{{ selected_community }}\", + getAttribute() { + return \"{{ selected_stack != 0 }}\"; + } + }], + }; - check_community_supports_title({ - target: document.getElementById(\"community_to_post_to\"), - }); - }, 250); + update_community_avatar({ target: fake_select }); + check_community_supports_title({ target: fake_select }); + }, 150); window.cancel_create_post = async () => { if ( diff --git a/crates/app/src/public/html/components.lisp b/crates/app/src/public/html/components.lisp index 505901a..8e5f11d 100644 --- a/crates/app/src/public/html/components.lisp +++ b/crates/app/src/public/html/components.lisp @@ -2659,5 +2659,5 @@ (text "{{ self::full_username(user=owner) }}")) (td (text "{{ post.comment_count }}")) (td (text "{{ ((post.likes + 1) / (post.dislikes + 1))|round(method=\"ceil\", precision=2) }}")) - (td (span ("class" "date") (text "{{ post.created }}")))) + (td (span ("class" "date short") (text "{{ post.created }}")))) (text "{%- endmacro %}") diff --git a/crates/app/src/routes/api/v1/communities/communities.rs b/crates/app/src/routes/api/v1/communities/communities.rs index afa9481..0d6d703 100644 --- a/crates/app/src/routes/api/v1/communities/communities.rs +++ b/crates/app/src/routes/api/v1/communities/communities.rs @@ -561,7 +561,7 @@ pub async fn add_topic_request( return Json(Error::DataTooLong("title".to_string()).into()); } - if req.title.len() < 2 { + if req.title.trim().len() < 2 { return Json(Error::DataTooShort("title".to_string()).into()); } @@ -618,7 +618,7 @@ pub async fn update_topic_request( return Json(Error::DataTooLong("title".to_string()).into()); } - if req.title.len() < 2 { + if req.title.trim().len() < 2 { return Json(Error::DataTooShort("title".to_string()).into()); } diff --git a/crates/core/src/database/apps.rs b/crates/core/src/database/apps.rs index 72334a8..b8555bd 100644 --- a/crates/core/src/database/apps.rs +++ b/crates/core/src/database/apps.rs @@ -64,7 +64,7 @@ impl DataManager { /// * `data` - a mock [`ThirdPartyApp`] object to insert pub async fn create_app(&self, data: ThirdPartyApp) -> Result { // check values - if data.title.len() < 2 { + if data.title.trim().len() < 2 { return Err(Error::DataTooShort("title".to_string())); } else if data.title.len() > 32 { return Err(Error::DataTooLong("title".to_string())); diff --git a/crates/core/src/database/communities.rs b/crates/core/src/database/communities.rs index e535d40..3b22917 100644 --- a/crates/core/src/database/communities.rs +++ b/crates/core/src/database/communities.rs @@ -207,7 +207,7 @@ impl DataManager { /// * `data` - a mock [`Community`] to insert pub async fn create_community(&self, data: Community) -> Result { // check values - if data.title.len() < 2 { + if data.title.trim().len() < 2 { return Err(Error::DataTooShort("title".to_string())); } else if data.title.len() > 32 { return Err(Error::DataTooLong("title".to_string())); diff --git a/crates/core/src/database/domains.rs b/crates/core/src/database/domains.rs index 737bd5f..2e20e0d 100644 --- a/crates/core/src/database/domains.rs +++ b/crates/core/src/database/domains.rs @@ -82,7 +82,7 @@ impl DataManager { /// * `data` - a mock [`Domain`] object to insert pub async fn create_domain(&self, data: Domain) -> Result { // check values - if data.name.len() < 2 { + if data.name.trim().len() < 2 { return Err(Error::DataTooShort("name".to_string())); } else if data.name.len() > 128 { return Err(Error::DataTooLong("name".to_string())); diff --git a/crates/core/src/database/posts.rs b/crates/core/src/database/posts.rs index 1e856dd..a98250f 100644 --- a/crates/core/src/database/posts.rs +++ b/crates/core/src/database/posts.rs @@ -1951,7 +1951,7 @@ impl DataManager { )); } } else if data.replying_to.is_none() { - if data.title.len() < 2 && community.context.require_titles { + if data.title.trim().len() < 2 && community.context.require_titles { return Err(Error::DataTooShort("title".to_string())); } else if data.title.len() > 128 { return Err(Error::DataTooLong("title".to_string())); diff --git a/crates/core/src/database/products.rs b/crates/core/src/database/products.rs index 0eab9aa..b5e32a5 100644 --- a/crates/core/src/database/products.rs +++ b/crates/core/src/database/products.rs @@ -89,7 +89,7 @@ impl DataManager { /// * `data` - a mock [`Product`] object to insert pub async fn create_product(&self, data: Product) -> Result { // check values - if data.name.len() < 2 { + if data.name.trim().len() < 2 { return Err(Error::DataTooShort("name".to_string())); } else if data.name.len() > 128 { return Err(Error::DataTooLong("name".to_string())); diff --git a/crates/core/src/database/services.rs b/crates/core/src/database/services.rs index adc9bc6..7c0e7bb 100644 --- a/crates/core/src/database/services.rs +++ b/crates/core/src/database/services.rs @@ -54,7 +54,7 @@ impl DataManager { /// * `data` - a mock [`Service`] object to insert pub async fn create_service(&self, data: Service) -> Result { // check values - if data.name.len() < 2 { + if data.name.trim().len() < 2 { return Err(Error::DataTooShort("name".to_string())); } else if data.name.len() > 128 { return Err(Error::DataTooLong("name".to_string())); diff --git a/crates/core/src/database/stacks.rs b/crates/core/src/database/stacks.rs index cea2be9..604c415 100644 --- a/crates/core/src/database/stacks.rs +++ b/crates/core/src/database/stacks.rs @@ -155,7 +155,7 @@ impl DataManager { /// * `data` - a mock [`UserStack`] object to insert pub async fn create_stack(&self, data: UserStack) -> Result { // check values - if data.name.len() < 2 { + if data.name.trim().len() < 2 { return Err(Error::DataTooShort("title".to_string())); } else if data.name.len() > 32 { return Err(Error::DataTooLong("title".to_string()));