mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-05-20 02:38:05 +00:00
Check markdown for tagline
This commit is contained in:
parent
ead51517e4
commit
abdfc90dbe
|
@ -18,7 +18,7 @@ pub struct CreateTagline {
|
|||
/// Update a tagline
|
||||
pub struct UpdateTagline {
|
||||
pub id: TaglineId,
|
||||
pub content: String,
|
||||
pub content: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash)]
|
||||
|
|
|
@ -3,15 +3,18 @@ use actix_web::web::Json;
|
|||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
tagline::{TaglineResponse, UpdateTagline},
|
||||
utils::is_admin,
|
||||
utils::{get_url_blocklist, is_admin, local_site_to_slur_regex, process_markdown_opt},
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
source::tagline::{Tagline, TaglineUpdateForm},
|
||||
source::{
|
||||
local_site::LocalSite,
|
||||
tagline::{Tagline, TaglineUpdateForm},
|
||||
},
|
||||
traits::Crud,
|
||||
utils::naive_now,
|
||||
};
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use lemmy_utils::{error::LemmyError, utils::validation::is_valid_body_field};
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn update_tagline(
|
||||
|
@ -22,8 +25,15 @@ pub async fn update_tagline(
|
|||
// Make sure user is an admin
|
||||
is_admin(&local_user_view)?;
|
||||
|
||||
let local_site = LocalSite::read(&mut context.pool()).await?;
|
||||
|
||||
let slur_regex = local_site_to_slur_regex(&local_site);
|
||||
let url_blocklist = get_url_blocklist(&context).await?;
|
||||
let content = process_markdown_opt(&data.content, &slur_regex, &url_blocklist, &context).await?;
|
||||
is_valid_body_field(&content, false)?;
|
||||
|
||||
let tagline_form = TaglineUpdateForm {
|
||||
content: Some(data.content.to_string()),
|
||||
content,
|
||||
updated: Some(Some(naive_now())),
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue