make limit for /api/v1/suggestions
authorHakaba Hitoyo <example@example.com>
Sun, 9 Sep 2018 04:57:23 +0000 (13:57 +0900)
committerHakaba Hitoyo <example@example.com>
Sun, 9 Sep 2018 04:57:23 +0000 (13:57 +0900)
config/config.exs
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
lib/pleroma/web/nodeinfo/nodeinfo_controller.ex

index d88a56adf1198dfd655f914b969027967d2691bf..ed718c3d3cd6f583a8a7d1a55f53a474abf2f5c5 100644 (file)
@@ -128,6 +128,7 @@ config :pleroma, :suggestions,
   third_party_engine:
     "http://vinayaka.distsn.org/cgi-bin/vinayaka-user-match-suggestions-api.cgi?{{host}}+{{user}}",
   timeout: 300_000,
+  limit: 23,
   web: "https://vinayaka.distsn.org/?{{host}}+{{user}}"
 
 # Import environment specific config. This must remain at the bottom
index f2fcc76ad6d53c2d2bd545dfdcaeb21e7dcc18bb..e5d4245c412a4a6383005cbf445e60fe0b1175e2 100644 (file)
@@ -1148,6 +1148,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
     if Keyword.get(@suggestions, :enabled, false) do
       api = Keyword.get(@suggestions, :third_party_engine, "")
       timeout = Keyword.get(@suggestions, :timeout, 5000)
+      limit = Keyword.get(@suggestions, :limit, 23)
 
       host =
         Application.get_env(:pleroma, Pleroma.Web.Endpoint)
@@ -1161,7 +1162,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
              @httpoison.get(url, [], timeout: timeout, recv_timeout: timeout),
            {:ok, data} <- Jason.decode(body) do
         data2 =
-          Enum.slice(data, 0, 40)
+          Enum.slice(data, 0, limit)
           |> Enum.map(fn x ->
             Map.put(
               x,
index 67cef004a1fde647c2e46abf0c25a8acaa509ed4..9c48274267122ce95f8c21cd6d5e0aa612411730 100644 (file)
@@ -59,6 +59,7 @@ defmodule Pleroma.Web.Nodeinfo.NodeinfoController do
           enabled: Keyword.get(suggestions, :enabled, false),
           thirdPartyEngine: Keyword.get(suggestions, :third_party_engine, ""),
           timeout: Keyword.get(suggestions, :timeout, 5000),
+          limit: Keyword.get(suggestions, :limit, 23),
           web: Keyword.get(suggestions, :web, "")
         },
         staffAccounts: staff_accounts,