- let (iframely_title, iframely_description, iframely_html, pictrs_thumbnail) =
- fetch_iframely_and_pictrs_data(context.client(), data_url).await;
-
- let post_form = PostForm {
- creator_id: orig_post.creator_id.to_owned(),
- community_id: orig_post.community_id,
- name: data.name.to_owned().unwrap_or(orig_post.name),
- url: data_url.map(|u| u.to_owned().into()),
- body: data.body.to_owned(),
- nsfw: data.nsfw,
- updated: Some(naive_now()),
- embed_title: iframely_title,
- embed_description: iframely_description,
- embed_html: iframely_html,
- thumbnail_url: pictrs_thumbnail.map(|u| u.into()),
- ..PostForm::default()
- };
-
- let post_id = data.post_id;
- let res = blocking(context.pool(), move |conn| {
- Post::update(conn, post_id, &post_form)
- })
+ let (metadata_res, thumbnail_url) =
+ fetch_site_data(context.client(), context.settings(), data_url, true).await;
+ let (embed_title, embed_description, embed_video_url) = metadata_res
+ .map(|u| (Some(u.title), Some(u.description), Some(u.embed_video_url)))
+ .unwrap_or_default();
+
+ let name = sanitize_html_opt(&data.name);
+ let body = sanitize_html_opt(&data.body);
+ let body = diesel_option_overwrite(body);
+ let embed_title = embed_title.map(|e| sanitize_html_opt(&e));
+ let embed_description = embed_description.map(|e| sanitize_html_opt(&e));
+
+ let language_id = self.language_id;
+ CommunityLanguage::is_allowed_community_language(
+ &mut context.pool(),
+ language_id,
+ orig_post.community_id,
+ )