1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.MastodonAPI.SuggestionController do
6 use Pleroma.Web, :controller
11 plug(Pleroma.Web.ApiSpec.CastAndValidate)
12 plug(Pleroma.Web.Plugs.OAuthScopesPlug, %{scopes: ["read"]} when action in [:index, :index2])
14 def open_api_operation(action) do
15 operation = String.to_existing_atom("#{action}_operation")
16 apply(__MODULE__, operation, [])
19 def index_operation do
20 %OpenApiSpex.Operation{
21 tags: ["Suggestions"],
22 summary: "Follow suggestions (Not implemented)",
23 operationId: "SuggestionController.index",
25 200 => Pleroma.Web.ApiSpec.Helpers.empty_array_response()
30 def index2_operation do
31 %OpenApiSpex.Operation{
32 tags: ["Suggestions"],
33 summary: "Follow suggestions",
34 operationId: "SuggestionController.index2",
36 200 => Pleroma.Web.ApiSpec.Helpers.empty_array_response()
41 @doc "GET /api/v1/suggestions"
42 def index(conn, params),
43 do: Pleroma.Web.MastodonAPI.MastodonAPIController.empty_array(conn, params)
45 @doc "GET /api/v2/suggestions"
46 def index2(%{assigns: %{user: user}} = conn, params) do
47 limit = Map.get(params, :limit, 40) |> min(80)
50 %{is_suggested: true, limit: limit}
54 render(conn, "index.json", %{users: users, source: :staff, for: user})