aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEgor Kislitsyn <egor@kislitsyn.com>2020-04-08 23:16:20 +0400
committerEgor Kislitsyn <egor@kislitsyn.com>2020-04-13 18:17:07 +0400
commitbd6e2b300f82e66afb121c2339c3cbbfb0b1a446 (patch)
tree001c4b4b1e039ee0f644a47d14820008a49e0bd8 /lib
parent03124c96cc192ef8c4893738a0cee552c6984da6 (diff)
downloadpleroma-bd6e2b300f82e66afb121c2339c3cbbfb0b1a446.tar.gz
Add spec for AccountController.followers
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/api_spec/operations/account_operation.ex19
-rw-r--r--lib/pleroma/web/api_spec/schemas/accounts_response.ex13
-rw-r--r--lib/pleroma/web/mastodon_api/controllers/account_controller.ex8
3 files changed, 38 insertions, 2 deletions
diff --git a/lib/pleroma/web/api_spec/operations/account_operation.ex b/lib/pleroma/web/api_spec/operations/account_operation.ex
index 09e6d24ed..070c74758 100644
--- a/lib/pleroma/web/api_spec/operations/account_operation.ex
+++ b/lib/pleroma/web/api_spec/operations/account_operation.ex
@@ -11,6 +11,7 @@ defmodule Pleroma.Web.ApiSpec.AccountOperation do
alias Pleroma.Web.ApiSpec.Schemas.AccountCreateRequest
alias Pleroma.Web.ApiSpec.Schemas.AccountCreateResponse
alias Pleroma.Web.ApiSpec.Schemas.AccountRelationshipsResponse
+ alias Pleroma.Web.ApiSpec.Schemas.AccountsResponse
alias Pleroma.Web.ApiSpec.Schemas.AccountUpdateCredentialsRequest
alias Pleroma.Web.ApiSpec.Schemas.BooleanLike
alias Pleroma.Web.ApiSpec.Schemas.StatusesResponse
@@ -139,7 +140,23 @@ defmodule Pleroma.Web.ApiSpec.AccountOperation do
end
def followers_operation do
- :ok
+ %Operation{
+ tags: ["accounts"],
+ summary: "Followers",
+ operationId: "AccountController.followers",
+ security: [%{"oAuth" => ["read:accounts"]}],
+ description:
+ "Accounts which follow the given account, if network is not hidden by the account owner.",
+ parameters: [
+ %Reference{"$ref": "#/components/parameters/accountIdOrNickname"},
+ Operation.parameter(:max_id, :query, :string, "Max ID"),
+ Operation.parameter(:since_id, :query, :string, "Since ID"),
+ Operation.parameter(:limit, :query, :integer, "Limit")
+ ],
+ responses: %{
+ 200 => Operation.response("Accounts", "application/json", AccountsResponse)
+ }
+ }
end
def following_operation, do: :ok
diff --git a/lib/pleroma/web/api_spec/schemas/accounts_response.ex b/lib/pleroma/web/api_spec/schemas/accounts_response.ex
new file mode 100644
index 000000000..b714f59e7
--- /dev/null
+++ b/lib/pleroma/web/api_spec/schemas/accounts_response.ex
@@ -0,0 +1,13 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Web.ApiSpec.Schemas.AccountsResponse do
+ require OpenApiSpex
+
+ OpenApiSpex.schema(%{
+ title: "AccountsResponse",
+ type: :array,
+ items: Pleroma.Web.ApiSpec.Schemas.Account
+ })
+end
diff --git a/lib/pleroma/web/mastodon_api/controllers/account_controller.ex b/lib/pleroma/web/mastodon_api/controllers/account_controller.ex
index 208df5698..1ffccdd1d 100644
--- a/lib/pleroma/web/mastodon_api/controllers/account_controller.ex
+++ b/lib/pleroma/web/mastodon_api/controllers/account_controller.ex
@@ -89,7 +89,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
:update_credentials,
:relationships,
:show,
- :statuses
+ :statuses,
+ :followers
]
)
@@ -284,6 +285,11 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
@doc "GET /api/v1/accounts/:id/followers"
def followers(%{assigns: %{user: for_user, account: user}} = conn, params) do
+ params =
+ params
+ |> Enum.map(fn {key, value} -> {to_string(key), value} end)
+ |> Enum.into(%{})
+
followers =
cond do
for_user && user.id == for_user.id -> MastodonAPI.get_followers(user, params)