mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-06-11 18:09:22 +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
|
/// Update a tagline
|
||||||
pub struct UpdateTagline {
|
pub struct UpdateTagline {
|
||||||
pub id: TaglineId,
|
pub id: TaglineId,
|
||||||
pub content: String,
|
pub content: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash)]
|
||||||
|
|
|
@ -3,15 +3,18 @@ use actix_web::web::Json;
|
||||||
use lemmy_api_common::{
|
use lemmy_api_common::{
|
||||||
context::LemmyContext,
|
context::LemmyContext,
|
||||||
tagline::{TaglineResponse, UpdateTagline},
|
tagline::{TaglineResponse, UpdateTagline},
|
||||||
utils::is_admin,
|
utils::{get_url_blocklist, is_admin, local_site_to_slur_regex, process_markdown_opt},
|
||||||
};
|
};
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
source::tagline::{Tagline, TaglineUpdateForm},
|
source::{
|
||||||
|
local_site::LocalSite,
|
||||||
|
tagline::{Tagline, TaglineUpdateForm},
|
||||||
|
},
|
||||||
traits::Crud,
|
traits::Crud,
|
||||||
utils::naive_now,
|
utils::naive_now,
|
||||||
};
|
};
|
||||||
use lemmy_db_views::structs::LocalUserView;
|
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))]
|
#[tracing::instrument(skip(context))]
|
||||||
pub async fn update_tagline(
|
pub async fn update_tagline(
|
||||||
|
@ -22,8 +25,15 @@ pub async fn update_tagline(
|
||||||
// Make sure user is an admin
|
// Make sure user is an admin
|
||||||
is_admin(&local_user_view)?;
|
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 {
|
let tagline_form = TaglineUpdateForm {
|
||||||
content: Some(data.content.to_string()),
|
content,
|
||||||
updated: Some(Some(naive_now())),
|
updated: Some(Some(naive_now())),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue