mirror of https://github.com/LemmyNet/lemmy.git
federate post url as image depending on mime type
parent
706841950d
commit
ecd8e3b11b
|
@ -234,7 +234,7 @@ async fn generate_pictrs_thumbnail(
|
|||
let pictrs_config = context.settings().pictrs_config()?;
|
||||
|
||||
if pictrs_config.disable_external_link_previews {
|
||||
return Ok(proxy_image_link(image_url.clone(), context)?);
|
||||
return Ok(proxy_image_link(image_url.clone(), context).await?.into());
|
||||
}
|
||||
|
||||
// fetch remote non-pictrs images for persistent thumbnail link
|
||||
|
|
|
@ -116,7 +116,7 @@ impl Object for ApubPost {
|
|||
let attachment = self
|
||||
.url
|
||||
.clone()
|
||||
.map(|url| Attachment::new(url, self.url_content_type.clone()))
|
||||
.map(|url| Attachment::new(url.into(), self.url_content_type.clone()))
|
||||
.into_iter()
|
||||
.collect();
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ use activitypub_federation::{
|
|||
use chrono::{DateTime, Utc};
|
||||
use itertools::Itertools;
|
||||
use lemmy_api_common::context::LemmyContext;
|
||||
use lemmy_db_schema::newtypes::DbUrl;
|
||||
use lemmy_utils::error::{LemmyError, LemmyErrorType};
|
||||
use serde::{de::Error, Deserialize, Deserializer, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
|
@ -168,12 +167,21 @@ impl Page {
|
|||
}
|
||||
|
||||
impl Attachment {
|
||||
pub(crate) fn new(url: DbUrl, media_type: Option<String>) -> Attachment {
|
||||
Attachment::Link(Link {
|
||||
href: url.into(),
|
||||
media_type,
|
||||
r#type: Default::default(),
|
||||
})
|
||||
/// Creates new attachment for a given link and mime type.
|
||||
pub(crate) fn new(url: Url, media_type: Option<String>) -> Attachment {
|
||||
let is_image = media_type.clone().unwrap_or_default().starts_with("image");
|
||||
if is_image {
|
||||
Attachment::Image(Image {
|
||||
kind: Default::default(),
|
||||
url,
|
||||
})
|
||||
} else {
|
||||
Attachment::Link(Link {
|
||||
href: url,
|
||||
media_type,
|
||||
r#type: Default::default(),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,8 @@ pub struct PictrsConfig {
|
|||
/// storage usage. It may also be necessary in certain countries which don't allow copying images
|
||||
/// from newspaper articles, but only allow hotlinking.
|
||||
///
|
||||
/// If this setting is enabled, the Opengraph image is directly returned as thumbnail.
|
||||
/// If this setting is enabled, the Opengraph image is directly returned as thumbnail. Note that
|
||||
/// it still gets proxied through the local instance if `image_proxy` is enabled.
|
||||
#[default(false)]
|
||||
pub disable_external_link_previews: bool,
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit e943f97fe481dc425acdebc8872bf1fdcabaf875
|
||||
Subproject commit 83540721c6035c701f4ef1daf7d95f78a51fedf7
|
Loading…
Reference in New Issue