Remove the Hackney follow_redirect
Change the get_media/4 to get_media/3 as we don't need to special case following redirects anymore and we probably should have always been following redirects anyway
This commit is contained in:
parent
02c62dd97f
commit
ef06b32d79
2 changed files with 4 additions and 19 deletions
|
@ -440,9 +440,6 @@ config :pleroma, :media_proxy,
|
|||
max_body_length: 25 * 1_048_576,
|
||||
# Note: max_read_duration defaults to Pleroma.ReverseProxy.max_read_duration_default/1
|
||||
max_read_duration: 30_000,
|
||||
http: [
|
||||
follow_redirect: true
|
||||
]
|
||||
],
|
||||
whitelist: []
|
||||
|
||||
|
|
|
@ -47,10 +47,9 @@ defmodule Pleroma.Web.Plugs.UploadedMedia do
|
|||
config = Pleroma.Config.get(Pleroma.Upload)
|
||||
|
||||
with uploader <- Keyword.fetch!(config, :uploader),
|
||||
proxy_remote = Keyword.get(config, :proxy_remote, false),
|
||||
{:ok, get_method} <- uploader.get_file(file),
|
||||
false <- media_is_banned(conn, get_method) do
|
||||
get_media(conn, get_method, proxy_remote, opts)
|
||||
get_media(conn, get_method, opts)
|
||||
else
|
||||
_ ->
|
||||
conn
|
||||
|
@ -69,7 +68,7 @@ defmodule Pleroma.Web.Plugs.UploadedMedia do
|
|||
|
||||
defp media_is_banned(_, _), do: false
|
||||
|
||||
defp get_media(conn, {:static_dir, directory}, _, opts) do
|
||||
defp get_media(conn, {:static_dir, directory}, opts) do
|
||||
static_opts =
|
||||
Map.get(opts, :static_plug_opts)
|
||||
|> Map.put(:at, [@path])
|
||||
|
@ -86,24 +85,13 @@ defmodule Pleroma.Web.Plugs.UploadedMedia do
|
|||
end
|
||||
end
|
||||
|
||||
defp get_media(conn, {:url, url}, true, _) do
|
||||
proxy_opts = [
|
||||
http: [
|
||||
follow_redirect: true
|
||||
]
|
||||
]
|
||||
|
||||
conn
|
||||
|> Pleroma.ReverseProxy.call(url, proxy_opts)
|
||||
end
|
||||
|
||||
defp get_media(conn, {:url, url}, _, _) do
|
||||
defp get_media(conn, {:url, url}, _) do
|
||||
conn
|
||||
|> Phoenix.Controller.redirect(external: url)
|
||||
|> halt()
|
||||
end
|
||||
|
||||
defp get_media(conn, unknown, _, _) do
|
||||
defp get_media(conn, unknown, _) do
|
||||
Logger.error("#{__MODULE__}: Unknown get startegy: #{inspect(unknown)}")
|
||||
|
||||
conn
|
||||
|
|
Loading…
Reference in a new issue