- let (metadata_res, thumbnail_url) = if let Some(url) = &url {
- fetch_site_data(context.client(), context.settings(), Some(url)).await
- } else {
- (None, page.image.map(|i| i.url.into()))
+ check_url_scheme(&url)?;
+
+ let local_site = LocalSite::read(&mut context.pool()).await.ok();
+ let allow_sensitive = local_site_opt_to_sensitive(&local_site);
+ let page_is_sensitive = page.sensitive.unwrap_or(false);
+ let include_image = allow_sensitive || !page_is_sensitive;
+
+ // Only fetch metadata if the post has a url and was not seen previously. We dont want to
+ // waste resources by fetching metadata for the same post multiple times.
+ // Additionally, only fetch image if content is not sensitive or is allowed on local site.
+ let (metadata_res, thumbnail) = match &url {
+ Some(url) if old_post.is_err() => {
+ fetch_site_data(
+ context.client(),
+ context.settings(),
+ Some(url),
+ include_image,
+ )
+ .await
+ }
+ _ => (None, None),