Config docs

This commit is contained in:
href 2018-11-30 17:44:42 +01:00
commit 680716b3c9
No known key found for this signature in database
GPG key ID: EE8296C1A152C325
3 changed files with 15 additions and 11 deletions

View file

@ -2,13 +2,15 @@ defmodule Pleroma.Web.MediaProxy.MediaProxyController do
use Pleroma.Web, :controller
alias Pleroma.{Web.MediaProxy, ReverseProxy}
@default_proxy_opts [max_body_length: 25 * 1_048_576]
def remote(conn, params = %{"sig" => sig64, "url" => url64}) do
with config <- Pleroma.Config.get([:media_proxy]),
true <- Keyword.get(config, :enabled, false),
{:ok, url} <- MediaProxy.decode_url(sig64, url64),
filename <- Path.basename(URI.parse(url).path),
:ok <- filename_matches(Map.has_key?(params, "filename"), conn.request_path, url) do
ReverseProxy.call(conn, url, Keyword.get(config, :proxy_opts, []))
ReverseProxy.call(conn, url, Keyword.get(config, :proxy_opts, @default_proxy_length))
else
false ->
send_resp(conn, 404, Plug.Conn.Status.reason_phrase(404))