From 9c8055d4b3eeed04e2fc27b69e1bd2b8bae11bb8 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Sun, 28 Jan 2024 12:29:12 -0500 Subject: [PATCH] Pleroma.Web.PleromaAPI.MascotController: dialyzer errors lib/pleroma/web/pleroma_api/controllers/mascot_controller.ex:25:no_return Function update/2 has no local return. lib/pleroma/web/pleroma_api/controllers/mascot_controller.ex:27:call The function call will not succeed. Pleroma.Web.ActivityPub.ActivityPub.upload(_file :: atom() | %{:content_type => _, _ => _}, [{:actor, <<_::56, _::size(8)>>}, ...]) :: :ok def a() do :ok end will never return since the 2nd arguments differ from the success typing arguments: (any(), [ {:activity_type | :description | :filters | :size_limit | :type | :uploader, atom() | binary() | [atom()] | non_neg_integer()} ]) lib/pleroma/web/pleroma_api/controllers/mascot_controller.ex:31:call The function call will not succeed. Phoenix.Controller.json( _conn :: %{ :assigns => %{:user => _, _ => _}, :body_params => %{:file => _, _ => _}, _ => _ }, _attachment :: any() ) breaks the contract (Plug.Conn.t(), term()) :: Plug.Conn.t() lib/pleroma/web/pleroma_api/controllers/mascot_controller.ex:34:call The function call will not succeed. Plug.Conn.put_status( _conn :: %{ :assigns => %{:user => _, _ => _}, :body_params => %{:file => _, _ => _}, _ => _ }, :unsupported_media_type ) breaks the contract (t(), status()) :: t() lib/pleroma/web/pleroma_api/controllers/mascot_controller.ex:34:call The function call will not succeed. Plug.Conn.put_status( _conn :: %{ :assigns => %{:user => _, _ => _}, :body_params => %{:file => _, _ => _}, _ => _ }, :unsupported_media_type ) breaks the contract (t(), status()) :: t() lib/pleroma/web/pleroma_api/controllers/mascot_controller.ex:38:unused_fun Function render_attachment/1 will never be called. --- lib/pleroma/upload.ex | 1 + lib/pleroma/web/api_spec/operations/pleroma_mascot_operation.ex | 2 +- lib/pleroma/web/pleroma_api/controllers/mascot_controller.ex | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/upload.ex b/lib/pleroma/upload.ex index 89cd3d920..e6c484548 100644 --- a/lib/pleroma/upload.ex +++ b/lib/pleroma/upload.ex @@ -51,6 +51,7 @@ defmodule Pleroma.Upload do | {:size_limit, nil | non_neg_integer()} | {:uploader, module()} | {:filters, [module()]} + | {:actor, String.t()} @type t :: %__MODULE__{ id: String.t(), diff --git a/lib/pleroma/web/api_spec/operations/pleroma_mascot_operation.ex b/lib/pleroma/web/api_spec/operations/pleroma_mascot_operation.ex index 775e27219..49c50751b 100644 --- a/lib/pleroma/web/api_spec/operations/pleroma_mascot_operation.ex +++ b/lib/pleroma/web/api_spec/operations/pleroma_mascot_operation.ex @@ -39,7 +39,7 @@ defmodule Pleroma.Web.ApiSpec.PleromaMascotOperation do %Schema{ type: :object, properties: %{ - file: %Schema{type: :string, format: :binary} + "file" => %Schema{type: :string, format: :binary} } }, required: true diff --git a/lib/pleroma/web/pleroma_api/controllers/mascot_controller.ex b/lib/pleroma/web/pleroma_api/controllers/mascot_controller.ex index 66e9d8481..9c0e4b3f1 100644 --- a/lib/pleroma/web/pleroma_api/controllers/mascot_controller.ex +++ b/lib/pleroma/web/pleroma_api/controllers/mascot_controller.ex @@ -22,7 +22,7 @@ defmodule Pleroma.Web.PleromaAPI.MascotController do end @doc "PUT /api/v1/pleroma/mascot" - def update(%{assigns: %{user: user}, body_params: %{file: file}} = conn, _) do + def update(%{assigns: %{user: user}, body_params: %{"file" => file}} = conn, _) do with {:content_type, "image" <> _} <- {:content_type, file.content_type}, {:ok, object} <- ActivityPub.upload(file, actor: User.ap_id(user)) do attachment = render_attachment(object)