You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
486 B

  1. class SearchService < BaseService
  2. def call(query, limit, resolve = false)
  3. return if query.blank?
  4. username, domain = query.split('@')
  5. results = if domain.nil?
  6. Account.search_for(username)
  7. else
  8. Account.search_for("#{username} #{domain}")
  9. end
  10. results = results.limit(limit).with_counters
  11. if resolve && results.empty? && !domain.nil?
  12. results = [FollowRemoteAccountService.new.call("#{username}@#{domain}")]
  13. end
  14. results
  15. end
  16. end