commit: a32d6b3aa4b922a4102cc1e6b0436775224d486d
parent 9c8055d4b3eeed04e2fc27b69e1bd2b8bae11bb8
Author: Mark Felder <feld@feld.me>
Date: Sun, 28 Jan 2024 12:35:45 -0500
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, _}
Diffstat:
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
@@ -23,8 +23,8 @@ defmodule Pleroma.Web.PleromaAPI.MascotController 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 @@ defmodule Pleroma.Web.PleromaAPI.MascotController do
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