logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git
commit: 9c8055d4b3eeed04e2fc27b69e1bd2b8bae11bb8
parent 563aebd5ce8e713dec2cb7ce47dbc7fc04473266
Author: Mark Felder <feld@feld.me>
Date:   Sun, 28 Jan 2024 12:29:12 -0500

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.

Diffstat:

Mlib/pleroma/upload.ex1+
Mlib/pleroma/web/api_spec/operations/pleroma_mascot_operation.ex2+-
Mlib/pleroma/web/pleroma_api/controllers/mascot_controller.ex2+-
3 files changed, 3 insertions(+), 2 deletions(-)

diff --git 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 @@ -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 @@ -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)