diff options
author | Mark Felder <feld@feld.me> | 2024-01-27 15:57:21 -0500 |
---|---|---|
committer | Mark Felder <feld@feld.me> | 2024-01-27 15:57:21 -0500 |
commit | 52e18a624922e64eb4a7fd3f0d7a9aef06ea7fad (patch) | |
tree | a9166e29a7818fc21550488a45b7a32438d8f3ea | |
parent | 17f4251b19846401ca36ee31156294ec63de84ee (diff) | |
download | pleroma-52e18a624922e64eb4a7fd3f0d7a9aef06ea7fad.tar.gz pleroma-52e18a624922e64eb4a7fd3f0d7a9aef06ea7fad.zip |
Pleroma.Web.PleromaAPI.UserImportController: Dialyzer errors
lib/pleroma/web/pleroma_api/controllers/user_import_controller.ex:53:call
The function call will not succeed.
Phoenix.Controller.json(
_conn :: %{
:assigns => %{:user => _, _ => _},
:body_params => %{:list => _, _ => _},
_ => _
},
<<106, 111, 98, 32, 115, 116, 97, 114, 116, 101, 100>>
)
breaks the contract
(Plug.Conn.t(), term()) :: Plug.Conn.t()
-rw-r--r-- | lib/pleroma/web/api_spec/operations/user_import_operation.ex | 4 | ||||
-rw-r--r-- | lib/pleroma/web/pleroma_api/controllers/user_import_controller.ex | 18 |
2 files changed, 11 insertions, 11 deletions
diff --git a/lib/pleroma/web/api_spec/operations/user_import_operation.ex b/lib/pleroma/web/api_spec/operations/user_import_operation.ex index e99e6e648..d12ebd968 100644 --- a/lib/pleroma/web/api_spec/operations/user_import_operation.ex +++ b/lib/pleroma/web/api_spec/operations/user_import_operation.ex @@ -61,9 +61,9 @@ defmodule Pleroma.Web.ApiSpec.UserImportOperation do defp import_request do %Schema{ type: :object, - required: [:list], + required: ["list"], properties: %{ - list: %Schema{ + "list" => %Schema{ description: "STRING or FILE containing a whitespace-separated list of accounts to import.", anyOf: [ diff --git a/lib/pleroma/web/pleroma_api/controllers/user_import_controller.ex b/lib/pleroma/web/pleroma_api/controllers/user_import_controller.ex index 90428a532..d0ae6d6e5 100644 --- a/lib/pleroma/web/pleroma_api/controllers/user_import_controller.ex +++ b/lib/pleroma/web/pleroma_api/controllers/user_import_controller.ex @@ -18,11 +18,11 @@ defmodule Pleroma.Web.PleromaAPI.UserImportController do plug(Pleroma.Web.ApiSpec.CastAndValidate) defdelegate open_api_operation(action), to: ApiSpec.UserImportOperation - def follow(%{body_params: %{list: %Plug.Upload{path: path}}} = conn, _) do - follow(%Plug.Conn{conn | body_params: %{list: File.read!(path)}}, %{}) + def follow(%{body_params: %{"list" => %Plug.Upload{path: path}}} = conn, _) do + follow(%Plug.Conn{conn | body_params: %{"list" => File.read!(path)}}, %{}) end - def follow(%{assigns: %{user: follower}, body_params: %{list: list}} = conn, _) do + def follow(%{assigns: %{user: follower}, body_params: %{"list" => list}} = conn, _) do identifiers = list |> String.split("\n") @@ -35,20 +35,20 @@ defmodule Pleroma.Web.PleromaAPI.UserImportController do json(conn, "job started") end - def blocks(%{body_params: %{list: %Plug.Upload{path: path}}} = conn, _) do - blocks(%Plug.Conn{conn | body_params: %{list: File.read!(path)}}, %{}) + def blocks(%{body_params: %{"list" => %Plug.Upload{path: path}}} = conn, _) do + blocks(%Plug.Conn{conn | body_params: %{"list" => File.read!(path)}}, %{}) end - def blocks(%{assigns: %{user: blocker}, body_params: %{list: list}} = conn, _) do + def blocks(%{assigns: %{user: blocker}, body_params: %{"list" => list}} = conn, _) do User.Import.blocks_import(blocker, prepare_user_identifiers(list)) json(conn, "job started") end - def mutes(%{body_params: %{list: %Plug.Upload{path: path}}} = conn, _) do - mutes(%Plug.Conn{conn | body_params: %{list: File.read!(path)}}, %{}) + def mutes(%{body_params: %{"list" => %Plug.Upload{path: path}}} = conn, _) do + mutes(%Plug.Conn{conn | body_params: %{"list" => File.read!(path)}}, %{}) end - def mutes(%{assigns: %{user: user}, body_params: %{list: list}} = conn, _) do + def mutes(%{assigns: %{user: user}, body_params: %{"list" => list}} = conn, _) do User.Import.mutes_import(user, prepare_user_identifiers(list)) json(conn, "job started") end |