mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-27 10:31:36 +01:00
21 lines
669 B
Ruby
21 lines
669 B
Ruby
# frozen_string_literal: true
|
|
|
|
class SearchService < BaseService
|
|
def call(query, limit, resolve = false, account = nil)
|
|
results = { accounts: [], hashtags: [], statuses: [] }
|
|
|
|
return results if query.blank?
|
|
|
|
if query =~ /\Ahttps?:\/\//
|
|
resource = FetchRemoteResourceService.new.call(query)
|
|
|
|
results[:accounts] << resource if resource.is_a?(Account)
|
|
results[:statuses] << resource if resource.is_a?(Status)
|
|
else
|
|
results[:accounts] = AccountSearchService.new.call(query, limit, resolve, account)
|
|
results[:hashtags] = Tag.search_for(query.gsub(/\A#/, ''), limit) unless query.start_with?('@')
|
|
end
|
|
|
|
results
|
|
end
|
|
end
|