- let (embed_title, embed_description, embed_html) = metadata_res
- .map(|u| (u.title, u.description, u.html))
- .unwrap_or((None, None, None));
- let body_slurs_removed = read_from_string_or_source_opt(&page.content, &page.source)
- .map(|s| remove_slurs(&s, &context.settings().slur_regex()));
-
- PostForm {
- name: page.name.clone(),
+ // If no image was included with metadata, use post image instead when available.
+ let thumbnail_url = thumbnail.or_else(|| page.image.map(|i| i.url.into()));
+
+ let (embed_title, embed_description, embed_video_url) = metadata_res
+ .map(|u| (u.title, u.description, u.embed_video_url))
+ .unwrap_or_default();
+ let slur_regex = &local_site_opt_to_slur_regex(&local_site);
+
+ let body_slurs_removed =
+ read_from_string_or_source_opt(&page.content, &page.media_type, &page.source)
+ .map(|s| remove_slurs(&s, slur_regex));
+ let language_id =
+ LanguageTag::to_language_id_single(page.language, &mut context.pool()).await?;
+
+ let name = sanitize_html(&name);
+ let embed_title = sanitize_html_opt(&embed_title);
+ let embed_description = sanitize_html_opt(&embed_description);
+
+ PostInsertForm {
+ name,