mirror of https://github.com/LemmyNet/lemmy.git
Fixing conversion, adding checks.
parent
9319c762a5
commit
495dd3f4f6
|
@ -57,10 +57,12 @@ pub async fn create_post(
|
|||
|
||||
let data_url = data.url.as_ref();
|
||||
let url = data_url.map(clean_url_params); // TODO no good way to handle a "clear"
|
||||
let custom_thumbnail = data.custom_thumbnail.as_ref().map(clean_url_params);
|
||||
|
||||
is_valid_post_title(&data.name)?;
|
||||
is_valid_body_field(&body, true)?;
|
||||
check_url_scheme(&data.url)?;
|
||||
check_url_scheme(&url)?;
|
||||
check_url_scheme(&custom_thumbnail)?;
|
||||
|
||||
check_community_user_action(
|
||||
&local_user_view.person,
|
||||
|
@ -87,7 +89,7 @@ pub async fn create_post(
|
|||
// Fetch post links and pictrs cached image
|
||||
let metadata = fetch_link_metadata_opt(url.as_ref(), true, &context).await;
|
||||
let url = proxy_image_link_opt_apub(url, &context).await?;
|
||||
let thumbnail_url = data.custom_thumbnail.or(metadata.thumbnail);
|
||||
let thumbnail_url = custom_thumbnail.map(Into::into).or(metadata.thumbnail);
|
||||
|
||||
// Only need to check if language is allowed in case user set it explicitly. When using default
|
||||
// language, it already only returns allowed languages.
|
||||
|
|
|
@ -43,6 +43,7 @@ pub async fn update_post(
|
|||
// TODO No good way to handle a clear.
|
||||
// Issue link: https://github.com/LemmyNet/lemmy/issues/2287
|
||||
let url = data.url.as_ref().map(clean_url_params);
|
||||
let custom_thumbnail = data.custom_thumbnail.as_ref().map(clean_url_params);
|
||||
|
||||
let slur_regex = local_site_to_slur_regex(&local_site);
|
||||
check_slurs_opt(&data.name, &slur_regex)?;
|
||||
|
@ -53,7 +54,8 @@ pub async fn update_post(
|
|||
}
|
||||
|
||||
is_valid_body_field(&body, true)?;
|
||||
check_url_scheme(&data.url)?;
|
||||
check_url_scheme(&url)?;
|
||||
check_url_scheme(&custom_thumbnail)?;
|
||||
|
||||
let post_id = data.post_id;
|
||||
let orig_post = Post::read(&mut context.pool(), post_id).await?;
|
||||
|
@ -78,7 +80,7 @@ pub async fn update_post(
|
|||
Some(metadata.opengraph_data.title),
|
||||
Some(metadata.opengraph_data.description),
|
||||
Some(metadata.opengraph_data.embed_video_url),
|
||||
Some(data.custom_thumbnail.or(metadata.thumbnail)),
|
||||
Some(custom_thumbnail.map(Into::into).or(metadata.thumbnail)),
|
||||
)
|
||||
}
|
||||
_ => Default::default(),
|
||||
|
|
Loading…
Reference in New Issue