diff --git a/crates/api_crud/src/tagline/create.rs b/crates/api_crud/src/tagline/create.rs index 01c5a8813..8111bd279 100644 --- a/crates/api_crud/src/tagline/create.rs +++ b/crates/api_crud/src/tagline/create.rs @@ -3,7 +3,7 @@ use actix_web::web::Json; use lemmy_api_common::{ context::LemmyContext, tagline::{CreateTagline, TaglineResponse}, - utils::{get_url_blocklist, is_admin, local_site_to_slur_regex, process_markdown_opt}, + utils::{get_url_blocklist, is_admin, local_site_to_slur_regex, process_markdown}, }; use lemmy_db_schema::{ source::{ @@ -28,18 +28,12 @@ pub async fn create_tagline( let slur_regex = local_site_to_slur_regex(&local_site); let url_blocklist = get_url_blocklist(&context).await?; - let processed_content = process_markdown_opt( - &Some(data.content.to_owned()), - &slur_regex, - &url_blocklist, - &context, - ) - .await?; - let content = is_valid_tagline_content(processed_content)?; + let content = process_markdown(&data.content, &slur_regex, &url_blocklist, &context).await?; + is_valid_tagline_content(&content)?; let tagline_form = TaglineInsertForm { local_site_id: local_site.id, - content, + content: content.clone(), }; let tagline = Tagline::create(&mut context.pool(), &tagline_form).await?; diff --git a/crates/api_crud/src/tagline/update.rs b/crates/api_crud/src/tagline/update.rs index e80193f3e..44a22f0c1 100644 --- a/crates/api_crud/src/tagline/update.rs +++ b/crates/api_crud/src/tagline/update.rs @@ -3,7 +3,7 @@ use actix_web::web::Json; use lemmy_api_common::{ context::LemmyContext, tagline::{TaglineResponse, UpdateTagline}, - utils::{get_url_blocklist, is_admin, local_site_to_slur_regex, process_markdown_opt}, + utils::{get_url_blocklist, is_admin, local_site_to_slur_regex, process_markdown}, }; use lemmy_db_schema::{ source::{ @@ -29,14 +29,8 @@ pub async fn update_tagline( let slur_regex = local_site_to_slur_regex(&local_site); let url_blocklist = get_url_blocklist(&context).await?; - let processed_content = process_markdown_opt( - &Some(data.content.to_owned()), - &slur_regex, - &url_blocklist, - &context, - ) - .await?; - let content = is_valid_tagline_content(processed_content)?; + let content = process_markdown(&data.content, &slur_regex, &url_blocklist, &context).await?; + is_valid_tagline_content(&content)?; let tagline_form = TaglineUpdateForm { content, diff --git a/crates/utils/src/utils/validation.rs b/crates/utils/src/utils/validation.rs index 3a2881151..067a7520c 100644 --- a/crates/utils/src/utils/validation.rs +++ b/crates/utils/src/utils/validation.rs @@ -171,23 +171,18 @@ pub fn is_valid_body_field(body: &Option, post: bool) -> LemmyResult<()> Ok(()) } -pub fn is_valid_tagline_content(content: Option) -> LemmyResult { - match content { - Some(content) => { - min_length_check( - &content, - TAGLINE_CONTENT_MIN_LENGTH, - LemmyErrorType::TaglineContentRequired, - )?; - max_length_check( - &content, - TAGLINE_CONTENT_MAX_LENGTH, - LemmyErrorType::TaglineContentLengthOverflow, - )?; - Ok(content) - } - None => Err(LemmyErrorType::TaglineContentRequired.into()), - } +pub fn is_valid_tagline_content(content: &str) -> LemmyResult<()> { + min_length_check( + content, + TAGLINE_CONTENT_MIN_LENGTH, + LemmyErrorType::TaglineContentRequired, + )?; + max_length_check( + content, + TAGLINE_CONTENT_MAX_LENGTH, + LemmyErrorType::TaglineContentLengthOverflow, + )?; + Ok(()) } pub fn is_valid_bio_field(bio: &str) -> LemmyResult<()> {