Search: limit number of results
authorAlex Gleason <alex@alexgleason.me>
Mon, 13 Dec 2021 04:50:07 +0000 (22:50 -0600)
committerAlex Gleason <alex@alexgleason.me>
Mon, 13 Dec 2021 04:50:07 +0000 (22:50 -0600)
lib/pleroma/web/mastodon_api/controllers/search_controller.ex

index 64b177eb3b11439e143fb4f40e1170c6bfa0d6f8..1459fc49233962e023454d3adfb508741292355a 100644 (file)
@@ -17,6 +17,8 @@ defmodule Pleroma.Web.MastodonAPI.SearchController do
 
   require Logger
 
+  @search_limit 40
+
   plug(Pleroma.Web.ApiSpec.CastAndValidate)
 
   # Note: Mastodon doesn't allow unauthenticated access (requires read:accounts / read:search)
@@ -77,7 +79,7 @@ defmodule Pleroma.Web.MastodonAPI.SearchController do
     [
       resolve: params[:resolve],
       following: params[:following],
-      limit: params[:limit],
+      limit: min(params[:limit], @search_limit),
       offset: params[:offset],
       type: params[:type],
       author: get_author(params),