diff --git a/crates/api_crud/src/post/create.rs b/crates/api_crud/src/post/create.rs index 89a710169..547c657cf 100644 --- a/crates/api_crud/src/post/create.rs +++ b/crates/api_crud/src/post/create.rs @@ -20,7 +20,7 @@ use lemmy_apub::{ use lemmy_db_queries::{source::post::Post_, Crud, Likeable}; use lemmy_db_schema::source::post::*; use lemmy_utils::{ - request::fetch_site_metadata_and_pictrs_data, + request::fetch_site_data, utils::{check_slurs, check_slurs_opt, clean_url_params, is_valid_post_title}, ApiError, ConnectionId, @@ -51,8 +51,7 @@ impl PerformCrud for CreatePost { // Fetch post links and pictrs cached image let data_url = data.url.as_ref(); - let (metadata_res, pictrs_thumbnail) = - fetch_site_metadata_and_pictrs_data(context.client(), data_url).await; + let (metadata_res, pictrs_thumbnail) = fetch_site_data(context.client(), data_url).await; let (embed_title, embed_description, embed_html) = metadata_res .map(|u| (u.title, u.description, u.html)) .unwrap_or((None, None, None)); diff --git a/crates/api_crud/src/post/update.rs b/crates/api_crud/src/post/update.rs index 9e0b54ed8..d52538e06 100644 --- a/crates/api_crud/src/post/update.rs +++ b/crates/api_crud/src/post/update.rs @@ -5,7 +5,7 @@ use lemmy_apub::activities::{post::create_or_update::CreateOrUpdatePost, CreateO use lemmy_db_queries::{source::post::Post_, Crud}; use lemmy_db_schema::{naive_now, source::post::*}; use lemmy_utils::{ - request::fetch_site_metadata_and_pictrs_data, + request::fetch_site_data, utils::{check_slurs_opt, clean_url_params, is_valid_post_title}, ApiError, ConnectionId, @@ -51,8 +51,7 @@ impl PerformCrud for EditPost { // Fetch post links and Pictrs cached image let data_url = data.url.as_ref(); - let (metadata_res, pictrs_thumbnail) = - fetch_site_metadata_and_pictrs_data(context.client(), data_url).await; + let (metadata_res, pictrs_thumbnail) = fetch_site_data(context.client(), data_url).await; let (embed_title, embed_description, embed_html) = metadata_res .map(|u| (u.title, u.description, u.html)) .unwrap_or((None, None, None)); diff --git a/crates/apub/src/objects/post.rs b/crates/apub/src/objects/post.rs index 67e161eed..4773f8c56 100644 --- a/crates/apub/src/objects/post.rs +++ b/crates/apub/src/objects/post.rs @@ -31,7 +31,7 @@ use lemmy_db_schema::{ }, }; use lemmy_utils::{ - request::fetch_site_metadata_and_pictrs_data, + request::fetch_site_data, utils::{check_slurs, convert_datetime, markdown_to_html, remove_slurs}, LemmyError, }; @@ -189,7 +189,7 @@ impl FromApub for Post { let thumbnail_url: Option = page.image.clone().map(|i| i.url); let (metadata_res, pictrs_thumbnail) = if let Some(url) = &page.url { - fetch_site_metadata_and_pictrs_data(context.client(), Some(url)).await + fetch_site_data(context.client(), Some(url)).await } else { (None, thumbnail_url) }; diff --git a/crates/utils/src/request.rs b/crates/utils/src/request.rs index a4825e4d8..a881cf02c 100644 --- a/crates/utils/src/request.rs +++ b/crates/utils/src/request.rs @@ -148,7 +148,8 @@ pub(crate) async fn fetch_pictrs( } /// Both are options, since the URL might be either an html page, or an image -pub async fn fetch_site_metadata_and_pictrs_data( +/// Returns the SiteMetadata, and a Pictrs URL, if there is a picture associated +pub async fn fetch_site_data( client: &Client, url: Option<&Url>, ) -> (Option, Option) {