about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2019-10-07 03:56:21 +0200
committerGitHub <noreply@github.com>2019-10-07 03:56:21 +0200
commit8386d9ec1001f8a938224190e518db054751b5a9 (patch)
treedb1007c298ea7ce7e4242e3e4a37f86fa5bfc582 /app
parenta58218562555c32bd0ec6c2ca2cc19ac4984904c (diff)
Fix hashtag timeline REST API accepting too many hashtags (#12091)
Diffstat (limited to 'app')
-rw-r--r--app/services/hashtag_query_service.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/app/services/hashtag_query_service.rb b/app/services/hashtag_query_service.rb
index 282821710..196de0639 100644
--- a/app/services/hashtag_query_service.rb
+++ b/app/services/hashtag_query_service.rb
@@ -1,6 +1,8 @@
 # frozen_string_literal: true
 
 class HashtagQueryService < BaseService
+  LIMIT_PER_MODE = 4
+
   def call(tag, params, account = nil, local = false)
     tags = tags_for(Array(tag.name) | Array(params[:any])).pluck(:id)
     all  = tags_for(params[:all])
@@ -15,6 +17,6 @@ class HashtagQueryService < BaseService
   private
 
   def tags_for(names)
-    Tag.matching_name(names) if names.presence
+    Tag.matching_name(Array(names).take(LIMIT_PER_MODE)) if names.present?
   end
 end