From 3d872b03e396e34b266aee6471ed55d93d4c0593 Mon Sep 17 00:00:00 2001
From: Kenneth Koski <kenneth.koski@canonical.com>
Date: Sat, 31 Oct 2020 17:08:03 -0500
Subject: [PATCH] Add iframely_url setting

---
 config/defaults.hjson       | 2 ++
 lemmy_utils/src/request.rs  | 2 +-
 lemmy_utils/src/settings.rs | 1 +
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/config/defaults.hjson b/config/defaults.hjson
index 0368500b..42222550 100644
--- a/config/defaults.hjson
+++ b/config/defaults.hjson
@@ -37,6 +37,8 @@
   jwt_secret: "changeme"
   # address where pictrs is available
   pictrs_url: "http://pictrs:8080"
+  # address where iframely is available
+  iframely_url: "http://iframely"
   # rate limits for various user actions, by user ip
   rate_limit: {
     # maximum number of messages created in interval
diff --git a/lemmy_utils/src/request.rs b/lemmy_utils/src/request.rs
index cbd778c6..6b282c47 100644
--- a/lemmy_utils/src/request.rs
+++ b/lemmy_utils/src/request.rs
@@ -58,7 +58,7 @@ pub(crate) async fn fetch_iframely(
   client: &Client,
   url: &str,
 ) -> Result<IframelyResponse, LemmyError> {
-  let fetch_url = format!("http://iframely/oembed?url={}", url);
+  let fetch_url = format!("{}/oembed?url={}", Settings::get().iframely_url, url);
 
   let response = retry(|| client.get(&fetch_url).send()).await?;
 
diff --git a/lemmy_utils/src/settings.rs b/lemmy_utils/src/settings.rs
index 797c6fba..3add60b3 100644
--- a/lemmy_utils/src/settings.rs
+++ b/lemmy_utils/src/settings.rs
@@ -15,6 +15,7 @@ pub struct Settings {
   pub tls_enabled: bool,
   pub jwt_secret: String,
   pub pictrs_url: String,
+  pub iframely_url: String,
   pub rate_limit: RateLimitConfig,
   pub email: Option<EmailConfig>,
   pub federation: FederationConfig,
-- 
2.44.1