- 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| clean_url_params(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)
- })
- .await?;
- let updated_post: Post = match res {
- Ok(post) => post,
- Err(e) => {
- let err_type = if e.to_string() == "value too long for type character varying(200)" {
- "post_title_too_long"
- } else {
- "couldnt_update_post"
- };
-
- return Err(ApiError::err(err_type).into());
- }
- };
-
- // Send apub update
- CreateOrUpdatePost::send(
- &updated_post,
- &local_user_view.person,
- CreateOrUpdateType::Update,
- context,
+ 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,