Add spec for AccountController.follows
[akkoma] / lib / pleroma / web / mastodon_api / controllers / account_controller.ex
index 1ecce292871f5ddebd458f5d3909a255d1ff614d..4340b9c8426e59bfd71416efed072240915a30e4 100644 (file)
@@ -94,7 +94,12 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
            :following,
            :lists,
            :follow,
-           :unfollow
+           :unfollow,
+           :mute,
+           :unmute,
+           :block,
+           :unblock,
+           :follows
          ]
   )
 
@@ -359,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})
@@ -399,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