diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2022-10-26 12:10:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-26 12:10:02 +0200 |
commit | 1ae508bf2faae016b88d15e273b0dc01de4fd7af (patch) | |
tree | 40e95ee7917ae867179b725bd88b34f911d07b7f /app/services | |
parent | 8f073818568b78b4adb858feb928b0da237d066a (diff) |
Change unauthenticated search to not support pagination in REST API (#19326)
- Only exact search matches for queries with < 5 characters - Do not support queries with `offset` (pagination) - Return HTTP 401 on truthy `resolve` instead of overriding to false
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/account_search_service.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/app/services/account_search_service.rb b/app/services/account_search_service.rb index 4dcae20eb..35b2e05f5 100644 --- a/app/services/account_search_service.rb +++ b/app/services/account_search_service.rb @@ -3,6 +3,9 @@ class AccountSearchService < BaseService attr_reader :query, :limit, :offset, :options, :account + # Min. number of characters to look for non-exact matches + MIN_QUERY_LENGTH = 5 + def call(query, account = nil, options = {}) @acct_hint = query&.start_with?('@') @query = query&.strip&.gsub(/\A@/, '') @@ -135,6 +138,8 @@ class AccountSearchService < BaseService end def limit_for_non_exact_results + return 0 if @account.nil? && query.size < MIN_QUERY_LENGTH + if exact_match? limit - 1 else |