Add spec for AccountController.follows
[akkoma] / lib / pleroma / web / mastodon_api / controllers / account_controller.ex
index e74180662fb495066f0113aa52a8144d94f78664..4340b9c8426e59bfd71416efed072240915a30e4 100644 (file)
@@ -91,7 +91,15 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
            :show,
            :statuses,
            :followers,
-           :following
+           :following,
+           :lists,
+           :follow,
+           :unfollow,
+           :mute,
+           :unmute,
+           :block,
+           :unblock,
+           :follows
          ]
   )
 
@@ -336,8 +344,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
     {:error, :not_found}
   end
 
-  def follow(%{assigns: %{user: follower, account: followed}} = conn, _params) do
-    with {:ok, follower} <- MastodonAPI.follow(follower, followed, conn.params) do
+  def follow(%{assigns: %{user: follower, account: followed}} = conn, params) do
+    with {:ok, follower} <- MastodonAPI.follow(follower, followed, params) do
       render(conn, "relationship.json", user: follower, target: followed)
     else
       {:error, message} -> json_response(conn, :forbidden, %{error: message})
@@ -356,10 +364,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
   end
 
   @doc "POST /api/v1/accounts/:id/mute"
-  def mute(%{assigns: %{user: muter, account: muted}} = conn, params) do
-    notifications? = params |> Map.get("notifications", true) |> truthy_param?()
-
-    with {:ok, _user_relationships} <- User.mute(muter, muted, notifications?) do
+  def mute(%{assigns: %{user: muter, account: muted}, body_params: params} = conn, _params) do
+    with {:ok, _user_relationships} <- User.mute(muter, muted, params.notifications) do
       render(conn, "relationship.json", user: muter, target: muted)
     else
       {:error, message} -> json_response(conn, :forbidden, %{error: message})
@@ -396,7 +402,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
   end
 
   @doc "POST /api/v1/follows"
-  def follows(%{assigns: %{user: follower}} = conn, %{"uri" => uri}) do
+  def follows(%{assigns: %{user: follower}, body_params: %{uri: uri}} = conn, _) do
     with {_, %User{} = followed} <- {:followed, User.get_cached_by_nickname(uri)},
          {_, true} <- {:followed, follower.id != followed.id},
          {:ok, follower, followed, _} <- CommonAPI.follow(follower, followed) do