The code powering m.abunchtell.com https://m.abunchtell.com
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.
 
 
 
 

24 lines
557 B

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