X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;ds=inline;f=lib%2Fpleroma%2Fweb%2Fplugs%2Fuploaded_media.ex;h=7b87d8f178defd9515ed9421aa68e0b753730633;hb=dbe678cb06352df49de4aa36f033b392ce6e6745;hp=402a8bb34c3d4b71f2decde632902601227c7041;hpb=78cea44553c936813ffc2c4c47984a64255096ef;p=akkoma
diff --git a/lib/pleroma/web/plugs/uploaded_media.ex b/lib/pleroma/web/plugs/uploaded_media.ex
index 402a8bb34..7b87d8f17 100644
--- a/lib/pleroma/web/plugs/uploaded_media.ex
+++ b/lib/pleroma/web/plugs/uploaded_media.ex
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors
+# Copyright © 2017-2021 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Plugs.UploadedMedia do
@@ -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
@@ -62,14 +61,14 @@ defmodule Pleroma.Web.Plugs.UploadedMedia do
def call(conn, _opts), do: conn
defp media_is_banned(%{request_path: path} = _conn, {:static_dir, _}) do
- MediaProxy.in_banned_urls(Pleroma.Web.base_url() <> path)
+ MediaProxy.in_banned_urls(Pleroma.Upload.base_url() <> path)
end
defp media_is_banned(_, {:url, url}), do: MediaProxy.in_banned_urls(url)
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,18 +85,13 @@ defmodule Pleroma.Web.Plugs.UploadedMedia do
end
end
- defp get_media(conn, {:url, url}, true, _) do
- conn
- |> Pleroma.ReverseProxy.call(url, Pleroma.Config.get([Pleroma.Upload, :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