You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
555 B

  1. # frozen_string_literal: true
  2. class Api::V1::SearchController < Api::BaseController
  3. RESULTS_LIMIT = 10
  4. before_action -> { doorkeeper_authorize! :read }
  5. before_action :require_user!
  6. respond_to :json
  7. def index
  8. @search = Search.new(search_results)
  9. render json: @search, serializer: REST::SearchSerializer
  10. end
  11. private
  12. def search_results
  13. SearchService.new.call(
  14. params[:q],
  15. RESULTS_LIMIT,
  16. resolving_search?,
  17. current_account
  18. )
  19. end
  20. def resolving_search?
  21. params[:resolve] == 'true'
  22. end
  23. end