From a3024dd5ac28bc23a91b12fa15ab56d15c1c341d Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Sun, 28 Jan 2024 16:35:30 -0500 Subject: [PATCH] Pleroma.Web.AdminAPI.InstanceDocumentController: fix dialyzer error lib/pleroma/web/admin_api/controllers/instance_document_controller.ex:32:call The function call will not succeed. Phoenix.Controller.json(_conn :: %{:body_params => %{:file => _, _ => _}, _ => _}, %{<<_::24>> => binary()}) :: :ok def a() do :ok end breaks the contract (Plug.Conn.t(), term()) :: Plug.Conn.t() --- .../web/admin_api/controllers/instance_document_controller.ex | 2 +- .../api_spec/operations/admin/instance_document_operation.ex | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pleroma/web/admin_api/controllers/instance_document_controller.ex b/lib/pleroma/web/admin_api/controllers/instance_document_controller.ex index 990a94313..a35878926 100644 --- a/lib/pleroma/web/admin_api/controllers/instance_document_controller.ex +++ b/lib/pleroma/web/admin_api/controllers/instance_document_controller.ex @@ -27,7 +27,7 @@ defmodule Pleroma.Web.AdminAPI.InstanceDocumentController do end end - def update(%{body_params: %{file: file}} = conn, %{name: document_name}) do + def update(%{body_params: %{"file" => file}} = conn, %{name: document_name}) do with {:ok, url} <- InstanceDocument.put(document_name, file.path) do json(conn, %{"url" => url}) end diff --git a/lib/pleroma/web/api_spec/operations/admin/instance_document_operation.ex b/lib/pleroma/web/api_spec/operations/admin/instance_document_operation.ex index fc0de499b..b2a1ba8ad 100644 --- a/lib/pleroma/web/api_spec/operations/admin/instance_document_operation.ex +++ b/lib/pleroma/web/api_spec/operations/admin/instance_document_operation.ex @@ -61,9 +61,9 @@ defmodule Pleroma.Web.ApiSpec.Admin.InstanceDocumentOperation do title: "UpdateRequest", description: "POST body for uploading the file", type: :object, - required: [:file], + required: ["file"], properties: %{ - file: %Schema{ + "file" => %Schema{ type: :string, format: :binary, description: "The file to be uploaded, using multipart form data."