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.
This commit is contained in:
Mark Felder 2024-01-28 12:29:12 -05:00
parent 563aebd5ce
commit 9c8055d4b3
3 changed files with 3 additions and 2 deletions

View File

@ -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(),

View File

@ -39,7 +39,7 @@ def update_operation do
%Schema{
type: :object,
properties: %{
file: %Schema{type: :string, format: :binary}
"file" => %Schema{type: :string, format: :binary}
}
},
required: true

View File

@ -22,7 +22,7 @@ def show(%{assigns: %{user: user}} = conn, _params) 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)