Add spec for AccountController.following

This commit is contained in:
Egor Kislitsyn 2020-04-08 23:38:07 +04:00
commit e105cc12b6
No known key found for this signature in database
GPG key ID: 1B49CB15B71E7805
3 changed files with 45 additions and 3 deletions

View file

@ -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

View file

@ -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)