From a32d6b3aa4b922a4102cc1e6b0436775224d486d Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Sun, 28 Jan 2024 12:35:45 -0500 Subject: [PATCH] Pleroma.Web.PleromaAPI.MascotController: dialyzer error lib/pleroma/web/pleroma_api/controllers/mascot_controller.ex:33:pattern_match The pattern can never match the type. Pattern: {:content_type, _} Type: {:error, _} --- .../web/pleroma_api/controllers/mascot_controller.ex | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/web/pleroma_api/controllers/mascot_controller.ex b/lib/pleroma/web/pleroma_api/controllers/mascot_controller.ex index 9c0e4b3f1..0533c348c 100644 --- a/lib/pleroma/web/pleroma_api/controllers/mascot_controller.ex +++ b/lib/pleroma/web/pleroma_api/controllers/mascot_controller.ex @@ -23,8 +23,8 @@ def show(%{assigns: %{user: user}} = conn, _params) do @doc "PUT /api/v1/pleroma/mascot" 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 + with {_, "image" <> _} <- {:content_type, file.content_type}, + {_, {:ok, object}} <- {:upload, ActivityPub.upload(file, actor: User.ap_id(user))} do attachment = render_attachment(object) {:ok, _user} = User.mascot_update(user, attachment) @@ -32,6 +32,9 @@ def update(%{assigns: %{user: user}, body_params: %{"file" => file}} = conn, _) else {:content_type, _} -> render_error(conn, :unsupported_media_type, "mascots can only be images") + + {:upload, {:error, _}} -> + render_error(conn, :error, "error uploading file") end end