summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Bracco <href@random.sh>2025-06-26 17:40:23 +0200
committerJordan Bracco <href@random.sh>2025-06-26 17:44:30 +0200
commitc869d17986093efab876a800b4f7b90bdac4c634 (patch)
tree1aa8b045eeed2484d4c9d2275d6298b1f7e5c0a2
parentlink: img.debrid-link: fix (diff)
link: reddit: use proxy in handler, rewrite to old reddit otherwise
-rw-r--r--lib/plugins/link/quirks.ex6
-rw-r--r--lib/plugins/link/reddit.ex8
2 files changed, 12 insertions, 2 deletions
diff --git a/lib/plugins/link/quirks.ex b/lib/plugins/link/quirks.ex
index af259a2..5acfdac 100644
--- a/lib/plugins/link/quirks.ex
+++ b/lib/plugins/link/quirks.ex
@@ -3,6 +3,12 @@ defmodule Nola.Plugins.Link.Quirks do
# %URI{uri | host: "vxtwitter.com"}
# end
+ # reddit: new reddit don't have titles for pages we don't handle in the reddit module
+ # fallback to old. which has nice titles
+ def uri(%URI{host: reddit} = uri) when reddit in ["www.reddit.com", "reddit.com"] do
+ %URI{uri | host: "old.reddit.com"}
+ end
+
def uri(url) do
url
end
diff --git a/lib/plugins/link/reddit.ex b/lib/plugins/link/reddit.ex
index bd38084..2a6527d 100644
--- a/lib/plugins/link/reddit.ex
+++ b/lib/plugins/link/reddit.ex
@@ -38,7 +38,9 @@ defmodule Nola.Plugins.Link.Reddit do
def expand(_, %{mode: :sub, sub: sub}, _opts) do
url = "https://api.reddit.com/r/#{sub}/about"
- case HTTPoison.get(url) do
+ case HTTPoison.get(url, [],
+ proxy: Keyword.get(Application.get_env(:nola, __MODULE__, []), :proxy, nil)
+ ) do
{:ok, %HTTPoison.Response{status_code: 200, body: body}} ->
sr =
Jason.decode!(body)
@@ -84,7 +86,9 @@ defmodule Nola.Plugins.Link.Reddit do
end
def expand(_uri, %{mode: :post, path: path, sub: sub, post_id: post_id}, _opts) do
- case HTTPoison.get("https://api.reddit.com#{path}?sr_detail=true") do
+ case HTTPoison.get("https://api.reddit.com#{path}?sr_detail=true", [],
+ proxy: Keyword.get(Application.get_env(:nola, __MODULE__, []), :proxy, nil)
+ ) do
{:ok, %HTTPoison.Response{status_code: 200, body: body}} ->
json = Jason.decode!(body)