aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEgor Kislitsyn <egor@kislitsyn.com>2020-04-08 23:38:07 +0400
committerEgor Kislitsyn <egor@kislitsyn.com>2020-04-13 18:17:07 +0400
commite105cc12b67e44eb4e19293b850731f300999a4f (patch)
tree707c911c8b73aaf1a4cd8ba7833721af31beb0cb /lib
parentbd6e2b300f82e66afb121c2339c3cbbfb0b1a446 (diff)
downloadpleroma-e105cc12b67e44eb4e19293b850731f300999a4f.tar.gz
Add spec for AccountController.following
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/api_spec/operations/account_operation.ex35
-rw-r--r--lib/pleroma/web/mastodon_api/controllers/account_controller.ex8
2 files changed, 40 insertions, 3 deletions
diff --git a/lib/pleroma/web/api_spec/operations/account_operation.ex b/lib/pleroma/web/api_spec/operations/account_operation.ex
index 070c74758..456d08a45 100644
--- a/lib/pleroma/web/api_spec/operations/account_operation.ex
+++ b/lib/pleroma/web/api_spec/operations/account_operation.ex
@@ -150,8 +150,40 @@ defmodule Pleroma.Web.ApiSpec.AccountOperation do
parameters: [
%Reference{"$ref": "#/components/parameters/accountIdOrNickname"},
Operation.parameter(:max_id, :query, :string, "Max ID"),
+ Operation.parameter(:min_id, :query, :string, "Mix ID"),
Operation.parameter(:since_id, :query, :string, "Since ID"),
- Operation.parameter(:limit, :query, :integer, "Limit")
+ Operation.parameter(
+ :limit,
+ :query,
+ %Schema{type: :integer, default: 20, maximum: 40},
+ "Limit"
+ )
+ ],
+ responses: %{
+ 200 => Operation.response("Accounts", "application/json", AccountsResponse)
+ }
+ }
+ end
+
+ def following_operation do
+ %Operation{
+ tags: ["accounts"],
+ summary: "Following",
+ operationId: "AccountController.following",
+ security: [%{"oAuth" => ["read:accounts"]}],
+ description:
+ "Accounts which the given account is following, 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(:min_id, :query, :string, "Mix ID"),
+ Operation.parameter(:since_id, :query, :string, "Since ID"),
+ Operation.parameter(
+ :limit,
+ :query,
+ %Schema{type: :integer, default: 20, maximum: 40},
+ "Limit"
+ )
],
responses: %{
200 => Operation.response("Accounts", "application/json", AccountsResponse)
@@ -159,7 +191,6 @@ defmodule Pleroma.Web.ApiSpec.AccountOperation do
}
end
- def following_operation, do: :ok
def lists_operation, do: :ok
def follow_operation, do: :ok
def unfollow_operation, do: :ok
diff --git a/lib/pleroma/web/mastodon_api/controllers/account_controller.ex b/lib/pleroma/web/mastodon_api/controllers/account_controller.ex
index 1ffccdd1d..e74180662 100644
--- a/lib/pleroma/web/mastodon_api/controllers/account_controller.ex
+++ b/lib/pleroma/web/mastodon_api/controllers/account_controller.ex
@@ -90,7 +90,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
:relationships,
:show,
:statuses,
- :followers
+ :followers,
+ :following
]
)
@@ -304,6 +305,11 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
@doc "GET /api/v1/accounts/:id/following"
def following(%{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_friends(user, params)