mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-05-20 02:38:05 +00:00
Use process_markdown instead of process_markdown_opt
This commit is contained in:
parent
7759602c9d
commit
6ffcc1f98a
|
@ -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?;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -171,23 +171,18 @@ pub fn is_valid_body_field(body: &Option<String>, post: bool) -> LemmyResult<()>
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn is_valid_tagline_content(content: Option<String>) -> LemmyResult<String> {
|
||||
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<()> {
|
||||
|
|
Loading…
Reference in a new issue