The code powering m.abunchtell.com https://m.abunchtell.com
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.
 
 
 
 

33 lines
675 B

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