From d0252c3893a06ed5ad6e3c79b7279cc3651988f6 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Fri, 12 Apr 2024 12:28:03 +0200 Subject: [PATCH] also consider opengraph image for local thumbnail generation --- crates/api_common/src/request.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/api_common/src/request.rs b/crates/api_common/src/request.rs index bc65c0864..ddb2a4551 100644 --- a/crates/api_common/src/request.rs +++ b/crates/api_common/src/request.rs @@ -103,12 +103,12 @@ pub fn generate_post_link_metadata( else if federated_thumbnail.is_some() { federated_thumbnail } - // Generate local thumbnail if allowed and post.url is Some - else if let (true, Some(url)) = (allow_generate_thumbnail, &post.url) { - generate_pictrs_thumbnail(url, &context) - .await - .ok() - .map(Into::into) + // Generate local thumbnail if allowed + else if allow_generate_thumbnail { + match post.url.or(metadata.opengraph_data.image) { + Some(url) => generate_pictrs_thumbnail(&url, &context).await.ok(), + None => None, + } } // Otherwise use opengraph preview image directly else {