Wip search visibility
This commit is contained in:
parent
5b4661c2f7
commit
165882a985
2 changed files with 3 additions and 15 deletions
|
@ -39,6 +39,6 @@ class Api::V2::SearchController < Api::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def search_params
|
def search_params
|
||||||
params.permit(:type, :offset, :min_id, :max_id, :account_id)
|
params.permit(:type, :offset, :min_id, :max_id, :account_id, :searchability)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,7 +8,7 @@ class SearchService < BaseService
|
||||||
@limit = limit.to_i
|
@limit = limit.to_i
|
||||||
@offset = options[:type].blank? ? 0 : options[:offset].to_i
|
@offset = options[:type].blank? ? 0 : options[:offset].to_i
|
||||||
@resolve = options[:resolve] || false
|
@resolve = options[:resolve] || false
|
||||||
@searchability = options[:searchability] || @account.user&.setting_default_searchability || 'private'
|
@searchability = options[:searchability] || 'public'
|
||||||
|
|
||||||
default_results.tap do |results|
|
default_results.tap do |results|
|
||||||
next if @query.blank? || @limit.zero?
|
next if @query.blank? || @limit.zero?
|
||||||
|
@ -69,7 +69,7 @@ class SearchService < BaseService
|
||||||
account_relations = relations_map_for_account(@account, account_ids, account_domains) # old name: preloaded_relations
|
account_relations = relations_map_for_account(@account, account_ids, account_domains) # old name: preloaded_relations
|
||||||
status_relations = relations_map_for_status(@account, results)
|
status_relations = relations_map_for_status(@account, results)
|
||||||
|
|
||||||
results.reject { |status| StatusFilter.new(status, @account, account_relations, status_relations).filtered? }
|
results.reject { |status| StatusFilter.new(status, @account, account_relations).filtered? }
|
||||||
rescue Faraday::ConnectionFailed, Parslet::ParseFailed
|
rescue Faraday::ConnectionFailed, Parslet::ParseFailed
|
||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
|
@ -139,18 +139,6 @@ class SearchService < BaseService
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def relations_map_for_status(account, statuses)
|
|
||||||
presenter = StatusRelationshipsPresenter.new(statuses, account)
|
|
||||||
{
|
|
||||||
reblogs_map: presenter.reblogs_map,
|
|
||||||
favourites_map: presenter.favourites_map,
|
|
||||||
bookmarks_map: presenter.bookmarks_map,
|
|
||||||
emoji_reactions_map: presenter.emoji_reactions_map,
|
|
||||||
mutes_map: presenter.mutes_map,
|
|
||||||
pins_map: presenter.pins_map,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
def parsed_query
|
def parsed_query
|
||||||
SearchQueryTransformer.new.apply(SearchQueryParser.new.parse(@query))
|
SearchQueryTransformer.new.apply(SearchQueryParser.new.parse(@query))
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue