summaryrefslogtreecommitdiff
path: root/lib/pleroma/web/mastodon_api/controllers/suggestion_controller.ex
diff options
context:
space:
mode:
authorAlex Gleason <alex@alexgleason.me>2021-11-26 14:33:27 -0600
committerAlex Gleason <alex@alexgleason.me>2021-11-26 14:34:10 -0600
commitb17360cd7c92d8b2337fa4fd175c3e1312eb352e (patch)
tree7baf4aa0551bea8d3c9ee8f73953860277775b5d /lib/pleroma/web/mastodon_api/controllers/suggestion_controller.ex
parent7e1caddc58bc6850f9780a9cd432b4b839f02e90 (diff)
downloadpleroma-b17360cd7c92d8b2337fa4fd175c3e1312eb352e.tar.gz
pleroma-b17360cd7c92d8b2337fa4fd175c3e1312eb352e.zip
v2 Suggestions: rudimentary API response
Diffstat (limited to 'lib/pleroma/web/mastodon_api/controllers/suggestion_controller.ex')
-rw-r--r--lib/pleroma/web/mastodon_api/controllers/suggestion_controller.ex15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/pleroma/web/mastodon_api/controllers/suggestion_controller.ex b/lib/pleroma/web/mastodon_api/controllers/suggestion_controller.ex
index b941849f5..a34da98df 100644
--- a/lib/pleroma/web/mastodon_api/controllers/suggestion_controller.ex
+++ b/lib/pleroma/web/mastodon_api/controllers/suggestion_controller.ex
@@ -4,6 +4,7 @@
defmodule Pleroma.Web.MastodonAPI.SuggestionController do
use Pleroma.Web, :controller
+ alias Pleroma.User
require Logger
@@ -29,7 +30,7 @@ defmodule Pleroma.Web.MastodonAPI.SuggestionController do
def index2_operation do
%OpenApiSpex.Operation{
tags: ["Suggestions"],
- summary: "Follow suggestions (Not implemented)",
+ summary: "Follow suggestions",
operationId: "SuggestionController.index2",
responses: %{
200 => Pleroma.Web.ApiSpec.Helpers.empty_array_response()
@@ -42,6 +43,14 @@ defmodule Pleroma.Web.MastodonAPI.SuggestionController do
do: Pleroma.Web.MastodonAPI.MastodonAPIController.empty_array(conn, params)
@doc "GET /api/v2/suggestions"
- def index2(conn, params),
- do: Pleroma.Web.MastodonAPI.MastodonAPIController.empty_array(conn, params)
+ def index2(conn, params) do
+ limit = Map.get(params, :limit, 40) |> min(80)
+
+ users =
+ %{is_suggested: true, limit: limit}
+ |> User.Query.build()
+ |> Pleroma.Repo.all()
+
+ render(conn, "index.json", %{users: users, source: :staff, skip_visibility_check: true})
+ end
end