From b6667105741c44d5ed102f6657b1b0ae77d4206b Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Mon, 29 Jan 2024 18:47:54 -0500 Subject: [PATCH] Pleroma.Web.MediaProxy.MediaProxyController: dialyzer errors lib/pleroma/web/media_proxy/media_proxy_controller.ex:55:no_return Function handle_preview/2 has no local return. ________________________________________________________________________________ lib/pleroma/web/media_proxy/media_proxy_controller.ex:59:call The function call will not succeed. Pleroma.HTTP.request(<<72, 69, 65, 68>>, _media_proxy_url :: any(), [], [], [{:pool, :media}]) will never return since the success typing is: ( :delete | :get | :head | :options | :patch | :post | :put | :trace, binary(), any(), [{binary(), binary()}], Keyword.t() ) :: any() and the contract is ( method(), Pleroma.HTTP.Request.url(), String.t(), Pleroma.HTTP.Request.headers(), :elixir.keyword() ) :: {:ok, Tesla.Env.t()} | {:error, any()} ________________________________________________________________________________ lib/pleroma/web/media_proxy/media_proxy_controller.ex:95:unused_fun Function handle_preview/3 will never be called. ________________________________________________________________________________ lib/pleroma/web/media_proxy/media_proxy_controller.ex:111:unused_fun Function handle_png_preview/2 will never be called. ________________________________________________________________________________ lib/pleroma/web/media_proxy/media_proxy_controller.ex:134:unused_fun Function handle_jpeg_preview/2 will never be called. ________________________________________________________________________________ lib/pleroma/web/media_proxy/media_proxy_controller.ex:152:unused_fun Function handle_video_preview/2 will never be called. ________________________________________________________________________________ lib/pleroma/web/media_proxy/media_proxy_controller.ex:164:unused_fun Function drop_static_param_and_redirect/1 will never be called. ________________________________________________________________________________ lib/pleroma/web/media_proxy/media_proxy_controller.ex:173:unused_fun Function fallback_on_preview_error/2 will never be called. ________________________________________________________________________________ lib/pleroma/web/media_proxy/media_proxy_controller.ex:177:unused_fun Function put_preview_response_headers/1 will never be called. ________________________________________________________________________________ lib/pleroma/web/media_proxy/media_proxy_controller.ex:177:unused_fun Function put_preview_response_headers/2 will never be called. ________________________________________________________________________________ lib/pleroma/web/media_proxy/media_proxy_controller.ex:187:unused_fun Function thumbnail_max_dimensions/0 will never be called. ________________________________________________________________________________ lib/pleroma/web/media_proxy/media_proxy_controller.ex:196:unused_fun Function min_content_length_for_preview/0 will never be called. ________________________________________________________________________________ lib/pleroma/web/media_proxy/media_proxy_controller.ex:200:unused_fun Function media_preview_proxy_config/0 will never be called. --- .../web/media_proxy/media_proxy_controller.ex | 2 +- .../media_proxy_controller_test.exs | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/pleroma/web/media_proxy/media_proxy_controller.ex b/lib/pleroma/web/media_proxy/media_proxy_controller.ex index bda5b36ed..c11484ecb 100644 --- a/lib/pleroma/web/media_proxy/media_proxy_controller.ex +++ b/lib/pleroma/web/media_proxy/media_proxy_controller.ex @@ -56,7 +56,7 @@ defp handle_preview(conn, url) do media_proxy_url = MediaProxy.url(url) with {:ok, %{status: status} = head_response} when status in 200..299 <- - Pleroma.HTTP.request("HEAD", media_proxy_url, [], [], pool: :media) do + Pleroma.HTTP.request(:head, media_proxy_url, "", [], pool: :media) do content_type = Tesla.get_header(head_response, "content-type") content_length = Tesla.get_header(head_response, "content-length") content_length = content_length && String.to_integer(content_length) diff --git a/test/pleroma/web/media_proxy/media_proxy_controller_test.exs b/test/pleroma/web/media_proxy/media_proxy_controller_test.exs index 5b3f5fbdc..f0c1dd640 100644 --- a/test/pleroma/web/media_proxy/media_proxy_controller_test.exs +++ b/test/pleroma/web/media_proxy/media_proxy_controller_test.exs @@ -182,7 +182,7 @@ test "responds with 424 Failed Dependency if HEAD request to media proxy fails", media_proxy_url: media_proxy_url } do Tesla.Mock.mock(fn - %{method: "HEAD", url: ^media_proxy_url} -> + %{method: :head, url: ^media_proxy_url} -> %Tesla.Env{status: 500, body: ""} end) @@ -197,7 +197,7 @@ test "redirects to media proxy URI on unsupported content type", %{ media_proxy_url: media_proxy_url } do Tesla.Mock.mock(fn - %{method: "HEAD", url: ^media_proxy_url} -> + %{method: :head, url: ^media_proxy_url} -> %Tesla.Env{status: 200, body: "", headers: [{"content-type", "application/pdf"}]} end) @@ -217,7 +217,7 @@ test "with `static=true` and GIF image preview requested, responds with JPEG ima clear_config([:media_preview_proxy, :min_content_length], 1_000_000_000) Tesla.Mock.mock(fn - %{method: "HEAD", url: ^media_proxy_url} -> + %{method: :head, url: ^media_proxy_url} -> %Tesla.Env{ status: 200, body: "", @@ -242,7 +242,7 @@ test "with GIF image preview requested and no `static` param, redirects to media media_proxy_url: media_proxy_url } do Tesla.Mock.mock(fn - %{method: "HEAD", url: ^media_proxy_url} -> + %{method: :head, url: ^media_proxy_url} -> %Tesla.Env{status: 200, body: "", headers: [{"content-type", "image/gif"}]} end) @@ -260,7 +260,7 @@ test "with `static` param and non-GIF image preview requested, " <> media_proxy_url: media_proxy_url } do Tesla.Mock.mock(fn - %{method: "HEAD", url: ^media_proxy_url} -> + %{method: :head, url: ^media_proxy_url} -> %Tesla.Env{status: 200, body: "", headers: [{"content-type", "image/jpeg"}]} end) @@ -280,7 +280,7 @@ test "with :min_content_length setting not matched by Content-Length header, " < clear_config([:media_preview_proxy, :min_content_length], 100_000) Tesla.Mock.mock(fn - %{method: "HEAD", url: ^media_proxy_url} -> + %{method: :head, url: ^media_proxy_url} -> %Tesla.Env{ status: 200, body: "", @@ -302,7 +302,7 @@ test "thumbnails PNG images into PNG", %{ assert_dependencies_installed() Tesla.Mock.mock(fn - %{method: "HEAD", url: ^media_proxy_url} -> + %{method: :head, url: ^media_proxy_url} -> %Tesla.Env{status: 200, body: "", headers: [{"content-type", "image/png"}]} %{method: :get, url: ^media_proxy_url} -> @@ -324,7 +324,7 @@ test "thumbnails JPEG images into JPEG", %{ assert_dependencies_installed() Tesla.Mock.mock(fn - %{method: "HEAD", url: ^media_proxy_url} -> + %{method: :head, url: ^media_proxy_url} -> %Tesla.Env{status: 200, body: "", headers: [{"content-type", "image/jpeg"}]} %{method: :get, url: ^media_proxy_url} -> @@ -344,7 +344,7 @@ test "redirects to media proxy URI in case of thumbnailing error", %{ media_proxy_url: media_proxy_url } do Tesla.Mock.mock(fn - %{method: "HEAD", url: ^media_proxy_url} -> + %{method: :head, url: ^media_proxy_url} -> %Tesla.Env{status: 200, body: "", headers: [{"content-type", "image/jpeg"}]} %{method: :get, url: ^media_proxy_url} ->