blob: 159c0371376e5575b1449c3bb04cdd9e88674104 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# frozen_string_literal: true
class SearchService < BaseService
def call(query, limit, resolve = false, account = nil)
return if query.blank?
results = { accounts: [], hashtags: [], statuses: [] }
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
|