This repository has been archived on 2024-06-09. You can view files and clone it, but cannot push or open issues/pull-requests.
2017-03-22 02:32:27 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-06-07 20:09:25 +02:00
|
|
|
class Api::V1::SearchController < Api::BaseController
|
2017-05-31 03:11:54 +02:00
|
|
|
RESULTS_LIMIT = 5
|
|
|
|
|
2017-07-11 17:08:26 +02:00
|
|
|
before_action -> { doorkeeper_authorize! :read }
|
|
|
|
before_action :require_user!
|
|
|
|
|
2017-03-22 02:32:27 +01:00
|
|
|
respond_to :json
|
|
|
|
|
|
|
|
def index
|
2017-07-07 04:02:06 +02:00
|
|
|
@search = Search.new(search_results)
|
|
|
|
render json: @search, serializer: REST::SearchSerializer
|
2017-05-31 03:11:54 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def search_results
|
|
|
|
SearchService.new.call(
|
|
|
|
params[:q],
|
|
|
|
RESULTS_LIMIT,
|
|
|
|
resolving_search?,
|
|
|
|
current_account
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def resolving_search?
|
|
|
|
params[:resolve] == 'true'
|
2017-03-22 02:32:27 +01:00
|
|
|
end
|
|
|
|
end
|