fix: trim forum post titles

This commit is contained in:
trisua 2025-08-04 23:29:24 -04:00
parent 80a39e7489
commit 9650c0177e
10 changed files with 22 additions and 17 deletions

View file

@ -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()));

View file

@ -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()));

View file

@ -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()));

View file

@ -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()));

View file

@ -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()));

View file

@ -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()));

View file

@ -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()));