mirror of https://github.com/LemmyNet/lemmy.git
fix setting
parent
33999171ad
commit
a88f4d6ef3
|
@ -870,7 +870,7 @@ pub async fn process_markdown_opt(
|
||||||
///
|
///
|
||||||
/// The parameter `force_image_proxy` is the config value of `pictrs.image_proxy`. Its necessary to pass
|
/// The parameter `force_image_proxy` is the config value of `pictrs.image_proxy`. Its necessary to pass
|
||||||
/// as separate parameter so it can be changed in tests.
|
/// as separate parameter so it can be changed in tests.
|
||||||
pub(crate) async fn proxy_image_link_wrapper(
|
async fn proxy_image_link_internal(
|
||||||
link: Url,
|
link: Url,
|
||||||
force_image_proxy: bool,
|
force_image_proxy: bool,
|
||||||
context: &LemmyContext,
|
context: &LemmyContext,
|
||||||
|
@ -892,7 +892,12 @@ pub(crate) async fn proxy_image_link_wrapper(
|
||||||
/// Rewrite a link to go through `/api/v3/image_proxy` endpoint. This is only for remote urls and
|
/// Rewrite a link to go through `/api/v3/image_proxy` endpoint. This is only for remote urls and
|
||||||
/// if image_proxy setting is enabled.
|
/// if image_proxy setting is enabled.
|
||||||
pub(crate) async fn proxy_image_link(link: Url, context: &LemmyContext) -> LemmyResult<DbUrl> {
|
pub(crate) async fn proxy_image_link(link: Url, context: &LemmyContext) -> LemmyResult<DbUrl> {
|
||||||
proxy_image_link_wrapper(link, false, context).await
|
proxy_image_link_internal(
|
||||||
|
link,
|
||||||
|
context.settings().pictrs_config()?.image_proxy,
|
||||||
|
context,
|
||||||
|
)
|
||||||
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn proxy_image_link_opt_api(
|
pub async fn proxy_image_link_opt_api(
|
||||||
|
@ -988,14 +993,14 @@ mod tests {
|
||||||
|
|
||||||
// image from local domain is unchanged
|
// image from local domain is unchanged
|
||||||
let local_url = Url::parse("http://lemmy-alpha/image.png").unwrap();
|
let local_url = Url::parse("http://lemmy-alpha/image.png").unwrap();
|
||||||
let proxied = proxy_image_link_wrapper(local_url.clone(), true, &context)
|
let proxied = proxy_image_link_internal(local_url.clone(), true, &context)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(&local_url, proxied.inner());
|
assert_eq!(&local_url, proxied.inner());
|
||||||
|
|
||||||
// image from remote domain is proxied
|
// image from remote domain is proxied
|
||||||
let remote_image = Url::parse("http://lemmy-beta/image.png").unwrap();
|
let remote_image = Url::parse("http://lemmy-beta/image.png").unwrap();
|
||||||
let proxied = proxy_image_link_wrapper(remote_image.clone(), true, &context)
|
let proxied = proxy_image_link_internal(remote_image.clone(), true, &context)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 15815aea74fe97360afc03496b3ad62588649af0
|
Subproject commit 06a610696af829248954e411ebe2cf3906092244
|
Loading…
Reference in New Issue