- defp proxy_request(link) do
- headers = [{"user-agent", "Pleroma/MediaProxy; #{Pleroma.Web.base_url()} <#{Application.get_env(:pleroma, :instance)[:email]}>"}]
- options = [:insecure, {:follow_redirect, true}]
- with \
- {:ok, 200, headers, client} <- :hackney.request(:get, link, headers, "", options),
- {:ok, body} <- proxy_request_body(client)
- do
- headers = Enum.into(headers, Map.new)
- {:ok, headers["Content-Type"], body}
- else
- {:ok, status, _, _} ->
- Logger.warn "MediaProxy: request failed, status #{status}, link: #{link}"
- {:error, {:http, :bad_status, link}}
- {:error, error} ->
- Logger.warn "MediaProxy: request failed, error #{inspect error}, link: #{link}"
- {:error, {:http, error, link}}
- end
- end
+ {:error, :invalid_signature} ->
+ send_resp(conn, 403, Plug.Conn.Status.reason_phrase(403))