Use finch everywhere #33
2 changed files with 4 additions and 19 deletions
|
@ -440,9 +440,6 @@
|
||||||
max_body_length: 25 * 1_048_576,
|
max_body_length: 25 * 1_048_576,
|
||||||
# Note: max_read_duration defaults to Pleroma.ReverseProxy.max_read_duration_default/1
|
# Note: max_read_duration defaults to Pleroma.ReverseProxy.max_read_duration_default/1
|
||||||
max_read_duration: 30_000,
|
max_read_duration: 30_000,
|
||||||
http: [
|
|
||||||
follow_redirect: true
|
|
||||||
]
|
|
||||||
],
|
],
|
||||||
whitelist: []
|
whitelist: []
|
||||||
|
|
||||||
|
|
|
@ -47,10 +47,9 @@ def call(%{request_path: <<"/", @path, "/", file::binary>>} = conn, opts) do
|
||||||
config = Pleroma.Config.get(Pleroma.Upload)
|
config = Pleroma.Config.get(Pleroma.Upload)
|
||||||
|
|
||||||
with uploader <- Keyword.fetch!(config, :uploader),
|
with uploader <- Keyword.fetch!(config, :uploader),
|
||||||
proxy_remote = Keyword.get(config, :proxy_remote, false),
|
|
||||||
{:ok, get_method} <- uploader.get_file(file),
|
{:ok, get_method} <- uploader.get_file(file),
|
||||||
false <- media_is_banned(conn, get_method) do
|
false <- media_is_banned(conn, get_method) do
|
||||||
get_media(conn, get_method, proxy_remote, opts)
|
get_media(conn, get_method, opts)
|
||||||
else
|
else
|
||||||
_ ->
|
_ ->
|
||||||
conn
|
conn
|
||||||
|
@ -69,7 +68,7 @@ defp media_is_banned(_, {:url, url}), do: MediaProxy.in_banned_urls(url)
|
||||||
|
|
||||||
defp media_is_banned(_, _), do: false
|
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 =
|
static_opts =
|
||||||
Map.get(opts, :static_plug_opts)
|
Map.get(opts, :static_plug_opts)
|
||||||
|> Map.put(:at, [@path])
|
|> Map.put(:at, [@path])
|
||||||
|
@ -86,24 +85,13 @@ defp get_media(conn, {:static_dir, directory}, _, opts) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp get_media(conn, {:url, url}, true, _) do
|
defp get_media(conn, {:url, url}, _) do
|
||||||
proxy_opts = [
|
|
||||||
http: [
|
|
||||||
follow_redirect: true
|
|
||||||
]
|
|
||||||
]
|
|
||||||
|
|
||||||
conn
|
|
||||||
|> Pleroma.ReverseProxy.call(url, proxy_opts)
|
|
||||||
end
|
|
||||||
|
|
||||||
defp get_media(conn, {:url, url}, _, _) do
|
|
||||||
conn
|
conn
|
||||||
|> Phoenix.Controller.redirect(external: url)
|
|> Phoenix.Controller.redirect(external: url)
|
||||||
|> halt()
|
|> halt()
|
||||||
end
|
end
|
||||||
|
|
||||||
defp get_media(conn, unknown, _, _) do
|
defp get_media(conn, unknown, _) do
|
||||||
Logger.error("#{__MODULE__}: Unknown get startegy: #{inspect(unknown)}")
|
Logger.error("#{__MODULE__}: Unknown get startegy: #{inspect(unknown)}")
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|
|
Loading…
Reference in a new issue