From 94838ed941494fb6132086aa2cb3b5e65a00b08c Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Sun, 28 Jan 2024 16:09:55 -0500 Subject: [PATCH] Pleroma.Web.AdminAPI.RelayController: dialyzer errors lib/pleroma/web/admin_api/controllers/relay_controller.ex:34:no_return Function follow/2 has no local return. ________________________________________________________________________________ lib/pleroma/web/admin_api/controllers/relay_controller.ex:38:call The function call will not succeed. Phoenix.Controller.json( _conn :: %{ :assigns => %{:user => _, _ => _}, :body_params => %{:relay_url => _, _ => _}, _ => _ }, %{:actor => binary(), :followed_back => boolean()} ) breaks the contract (Plug.Conn.t(), term()) :: Plug.Conn.t() ________________________________________________________________________________ lib/pleroma/web/admin_api/controllers/relay_controller.ex:41:call The function call will not succeed. Plug.Conn.put_status( _conn :: %{ :assigns => %{:user => _, _ => _}, :body_params => %{:relay_url => _, _ => _}, _ => _ }, 500 ) breaks the contract (t(), status()) :: t() ________________________________________________________________________________ lib/pleroma/web/admin_api/controllers/relay_controller.ex:47:no_return Function unfollow/2 has no local return. ________________________________________________________________________________ lib/pleroma/web/admin_api/controllers/relay_controller.ex:51:call The function call will not succeed. Phoenix.Controller.json( _conn :: %{ :assigns => %{:user => _, _ => _}, :body_params => %{:relay_url => _, _ => _}, _ => _ }, _target :: binary() ) breaks the contract (Plug.Conn.t(), term()) :: Plug.Conn.t() ________________________________________________________________________________ lib/pleroma/web/admin_api/controllers/relay_controller.ex:54:call The function call will not succeed. Plug.Conn.put_status( _conn :: %{ :assigns => %{:user => _, _ => _}, :body_params => %{:relay_url => _, _ => _}, _ => _ }, 500 ) breaks the contract (t(), status()) :: t() --- .../web/admin_api/controllers/relay_controller.ex | 9 ++++++--- .../web/api_spec/operations/admin/relay_operation.ex | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/pleroma/web/admin_api/controllers/relay_controller.ex b/lib/pleroma/web/admin_api/controllers/relay_controller.ex index 2e83fe139..664011b06 100644 --- a/lib/pleroma/web/admin_api/controllers/relay_controller.ex +++ b/lib/pleroma/web/admin_api/controllers/relay_controller.ex @@ -31,7 +31,7 @@ defmodule Pleroma.Web.AdminAPI.RelayController do end end - def follow(%{assigns: %{user: admin}, body_params: %{relay_url: target}} = conn, _) do + def follow(%{assigns: %{user: admin}, body_params: %{"relay_url" => target}} = conn, _) do with {:ok, _message} <- Relay.follow(target) do ModerationLog.insert_log(%{action: "relay_follow", actor: admin, target: target}) @@ -44,8 +44,11 @@ defmodule Pleroma.Web.AdminAPI.RelayController do end end - def unfollow(%{assigns: %{user: admin}, body_params: %{relay_url: target} = params} = conn, _) do - with {:ok, _message} <- Relay.unfollow(target, %{force: params[:force]}) do + def unfollow( + %{assigns: %{user: admin}, body_params: %{"relay_url" => target} = params} = conn, + _ + ) do + with {:ok, _message} <- Relay.unfollow(target, %{force: params["force"]}) do ModerationLog.insert_log(%{action: "relay_unfollow", actor: admin, target: target}) json(conn, target) diff --git a/lib/pleroma/web/api_spec/operations/admin/relay_operation.ex b/lib/pleroma/web/api_spec/operations/admin/relay_operation.ex index 8b241bd49..ca9080fb3 100644 --- a/lib/pleroma/web/api_spec/operations/admin/relay_operation.ex +++ b/lib/pleroma/web/api_spec/operations/admin/relay_operation.ex @@ -87,7 +87,7 @@ defmodule Pleroma.Web.ApiSpec.Admin.RelayOperation do %Schema{ type: :object, properties: %{ - relay_url: %Schema{type: :string, format: :uri} + "relay_url" => %Schema{type: :string, format: :uri} } } end @@ -96,8 +96,8 @@ defmodule Pleroma.Web.ApiSpec.Admin.RelayOperation do %Schema{ type: :object, properties: %{ - relay_url: %Schema{type: :string, format: :uri}, - force: %Schema{type: :boolean, default: false} + "relay_url" => %Schema{type: :string, format: :uri}, + "force" => %Schema{type: :boolean, default: false} } } end