Add specs for AccountController.block and AccountController.unblock
authorEgor Kislitsyn <egor@kislitsyn.com>
Thu, 9 Apr 2020 14:41:18 +0000 (18:41 +0400)
committerEgor Kislitsyn <egor@kislitsyn.com>
Mon, 13 Apr 2020 14:17:08 +0000 (18:17 +0400)
lib/pleroma/web/api_spec/operations/account_operation.ex
lib/pleroma/web/mastodon_api/controllers/account_controller.ex
test/web/mastodon_api/controllers/account_controller_test.exs

index 62ae2eead3f4efaeb174e67462d376fea8d9ead5..73fbe87850cb41de396d7ad8c96506899a784494 100644 (file)
@@ -278,8 +278,35 @@ defmodule Pleroma.Web.ApiSpec.AccountOperation do
     }
   end
 
-  def block_operation, do: :ok
-  def unblock_operation, do: :ok
+  def block_operation do
+    %Operation{
+      tags: ["accounts"],
+      summary: "Block",
+      operationId: "AccountController.block",
+      security: [%{"oAuth" => ["follow", "write:blocks"]}],
+      description:
+        "Block the given account. Clients should filter statuses from this account if received (e.g. due to a boost in the Home timeline)",
+      parameters: [%Reference{"$ref": "#/components/parameters/accountIdOrNickname"}],
+      responses: %{
+        200 => Operation.response("Relationship", "application/json", AccountRelationship)
+      }
+    }
+  end
+
+  def unblock_operation do
+    %Operation{
+      tags: ["accounts"],
+      summary: "Unblock",
+      operationId: "AccountController.unblock",
+      security: [%{"oAuth" => ["follow", "write:blocks"]}],
+      description: "Unblock the given account.",
+      parameters: [%Reference{"$ref": "#/components/parameters/accountIdOrNickname"}],
+      responses: %{
+        200 => Operation.response("Relationship", "application/json", AccountRelationship)
+      }
+    }
+  end
+
   def follows_operation, do: :ok
   def mutes_operation, do: :ok
   def blocks_operation, do: :ok
index 9aba2e094f6237406b909d1d79d4525762a4c6b3..c1f70f32c48fb867eaeb91c69ff266fceecf6002 100644 (file)
@@ -96,7 +96,9 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
            :follow,
            :unfollow,
            :mute,
-           :unmute
+           :unmute,
+           :block,
+           :unblock
          ]
   )
 
index 91d4685cb68b030e2d7cdb780d7354c61dcf0d1a..f71b54ade0c5b5444d0e2bf78557f3e90f6e10ed 100644 (file)
@@ -819,10 +819,12 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
     ret_conn = post(conn, "/api/v1/accounts/#{other_user.id}/block")
 
     assert %{"id" => _id, "blocking" => true} = json_response(ret_conn, 200)
+    assert_schema(json_response(ret_conn, 200), "AccountRelationship", ApiSpec.spec())
 
     conn = post(conn, "/api/v1/accounts/#{other_user.id}/unblock")
 
     assert %{"id" => _id, "blocking" => false} = json_response(conn, 200)
+    assert_schema(json_response(ret_conn, 200), "AccountRelationship", ApiSpec.spec())
   end
 
   describe "create account by app" do