fix: trim forum post titles
This commit is contained in:
parent
80a39e7489
commit
9650c0177e
10 changed files with 22 additions and 17 deletions
|
@ -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 (
|
||||
|
|
|
@ -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 %}")
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ impl DataManager {
|
|||
/// * `data` - a mock [`ThirdPartyApp`] object to insert
|
||||
pub async fn create_app(&self, data: ThirdPartyApp) -> Result<ThirdPartyApp> {
|
||||
// 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()));
|
||||
|
|
|
@ -207,7 +207,7 @@ impl DataManager {
|
|||
/// * `data` - a mock [`Community`] to insert
|
||||
pub async fn create_community(&self, data: Community) -> Result<String> {
|
||||
// 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()));
|
||||
|
|
|
@ -82,7 +82,7 @@ impl DataManager {
|
|||
/// * `data` - a mock [`Domain`] object to insert
|
||||
pub async fn create_domain(&self, data: Domain) -> Result<Domain> {
|
||||
// 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()));
|
||||
|
|
|
@ -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()));
|
||||
|
|
|
@ -89,7 +89,7 @@ impl DataManager {
|
|||
/// * `data` - a mock [`Product`] object to insert
|
||||
pub async fn create_product(&self, data: Product) -> Result<Product> {
|
||||
// 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()));
|
||||
|
|
|
@ -54,7 +54,7 @@ impl DataManager {
|
|||
/// * `data` - a mock [`Service`] object to insert
|
||||
pub async fn create_service(&self, data: Service) -> Result<Service> {
|
||||
// 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()));
|
||||
|
|
|
@ -155,7 +155,7 @@ impl DataManager {
|
|||
/// * `data` - a mock [`UserStack`] object to insert
|
||||
pub async fn create_stack(&self, data: UserStack) -> Result<UserStack> {
|
||||
// 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()));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue