mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-24 16:18:07 +01:00
1b8fcd4df5
Conflicts: README.md app/controllers/follower_accounts_controller.rb app/controllers/following_accounts_controller.rb app/serializers/rest/instance_serializer.rb app/views/stream_entries/_simple_status.html.haml config/locales/simple_form.ja.yml
40 lines
753 B
Ruby
40 lines
753 B
Ruby
# frozen_string_literal: true
|
|
|
|
class Api::V1::SearchController < Api::BaseController
|
|
include Authorization
|
|
|
|
RESULTS_LIMIT = 10
|
|
|
|
before_action -> { doorkeeper_authorize! :read }
|
|
before_action :require_user!
|
|
|
|
respond_to :json
|
|
|
|
def index
|
|
@search = Search.new(search)
|
|
render json: @search, serializer: REST::SearchSerializer
|
|
end
|
|
|
|
private
|
|
|
|
def search
|
|
search_results.tap do |search|
|
|
search[:statuses].keep_if do |status|
|
|
begin
|
|
authorize status, :show?
|
|
rescue Mastodon::NotPermittedError
|
|
false
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
def search_results
|
|
SearchService.new.call(
|
|
params[:q],
|
|
RESULTS_LIMIT,
|
|
truthy_param?(:resolve),
|
|
current_account
|
|
)
|
|
end
|
|
end
|