Use the configured http client options for mediaproxy
This commit is contained in:
parent
d272eb62cd
commit
37d79b76bb
|
@ -11,11 +11,6 @@ defmodule Pleroma.Web.ActivityPub.MRF.MediaProxyWarmingPolicy do
|
||||||
|
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
@adapter_options [
|
|
||||||
pool: :media,
|
|
||||||
recv_timeout: 10_000
|
|
||||||
]
|
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def history_awareness, do: :auto
|
def history_awareness, do: :auto
|
||||||
|
|
||||||
|
@ -35,7 +30,10 @@ defp prefetch(url) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp fetch(url), do: HTTP.get(url, [], @adapter_options)
|
defp fetch(url) do
|
||||||
|
http_client_opts = Pleroma.Config.get([:media_proxy, :proxy_opts, :http], pool: :media)
|
||||||
|
HTTP.get(url, [], http_client_opts)
|
||||||
|
end
|
||||||
|
|
||||||
defp preload(%{"object" => %{"attachment" => attachments}} = _message) do
|
defp preload(%{"object" => %{"attachment" => attachments}} = _message) do
|
||||||
Enum.each(attachments, fn
|
Enum.each(attachments, fn
|
||||||
|
|
|
@ -54,9 +54,10 @@ def preview(%Conn{} = conn, %{"sig" => sig64, "url" => url64}) do
|
||||||
|
|
||||||
defp handle_preview(conn, url) do
|
defp handle_preview(conn, url) do
|
||||||
media_proxy_url = MediaProxy.url(url)
|
media_proxy_url = MediaProxy.url(url)
|
||||||
|
http_client_opts = Pleroma.Config.get([:media_proxy, :proxy_opts, :http], pool: :media)
|
||||||
|
|
||||||
with {:ok, %{status: status} = head_response} when status in 200..299 <-
|
with {:ok, %{status: status} = head_response} when status in 200..299 <-
|
||||||
Pleroma.HTTP.request(:head, media_proxy_url, "", [], pool: :media) do
|
Pleroma.HTTP.request(:head, media_proxy_url, "", [], http_client_opts) do
|
||||||
content_type = Tesla.get_header(head_response, "content-type")
|
content_type = Tesla.get_header(head_response, "content-type")
|
||||||
content_length = Tesla.get_header(head_response, "content-length")
|
content_length = Tesla.get_header(head_response, "content-length")
|
||||||
content_length = content_length && String.to_integer(content_length)
|
content_length = content_length && String.to_integer(content_length)
|
||||||
|
|
Loading…
Reference in New Issue