mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-23 06:58:58 +00:00
[#2497] Media preview proxy: redirecting to media proxy url in case of preview error or unsupported content type.
This commit is contained in:
parent
0bda85857e
commit
32831f371f
|
@ -91,8 +91,8 @@ defmodule Pleroma.Web.MediaProxy.MediaProxyController do
|
||||||
handle_video_preview(conn, media_proxy_url)
|
handle_video_preview(conn, media_proxy_url)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp handle_preview(content_type, conn, _media_proxy_url) do
|
defp handle_preview(_unsupported_content_type, conn, media_proxy_url) do
|
||||||
send_resp(conn, :unprocessable_entity, "Unsupported content type: #{content_type}.")
|
fallback_on_preview_error(conn, media_proxy_url)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp handle_png_preview(conn, media_proxy_url) do
|
defp handle_png_preview(conn, media_proxy_url) do
|
||||||
|
@ -114,7 +114,7 @@ defmodule Pleroma.Web.MediaProxy.MediaProxyController do
|
||||||
|> send_resp(200, thumbnail_binary)
|
|> send_resp(200, thumbnail_binary)
|
||||||
else
|
else
|
||||||
_ ->
|
_ ->
|
||||||
send_resp(conn, :failed_dependency, "Can't handle preview.")
|
fallback_on_preview_error(conn, media_proxy_url)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ defmodule Pleroma.Web.MediaProxy.MediaProxyController do
|
||||||
|> send_resp(200, thumbnail_binary)
|
|> send_resp(200, thumbnail_binary)
|
||||||
else
|
else
|
||||||
_ ->
|
_ ->
|
||||||
send_resp(conn, :failed_dependency, "Can't handle preview.")
|
fallback_on_preview_error(conn, media_proxy_url)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -144,10 +144,14 @@ defmodule Pleroma.Web.MediaProxy.MediaProxyController do
|
||||||
|> send_resp(200, thumbnail_binary)
|
|> send_resp(200, thumbnail_binary)
|
||||||
else
|
else
|
||||||
_ ->
|
_ ->
|
||||||
send_resp(conn, :failed_dependency, "Can't handle preview.")
|
fallback_on_preview_error(conn, media_proxy_url)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp fallback_on_preview_error(conn, media_proxy_url) do
|
||||||
|
redirect(conn, external: media_proxy_url)
|
||||||
|
end
|
||||||
|
|
||||||
defp put_preview_response_headers(
|
defp put_preview_response_headers(
|
||||||
conn,
|
conn,
|
||||||
[content_type, filename] = _content_info \\ ["image/jpeg", "preview.jpg"]
|
[content_type, filename] = _content_info \\ ["image/jpeg", "preview.jpg"]
|
||||||
|
|
Loading…
Reference in a new issue