logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

instance_filter.rb (485B)


  1. # frozen_string_literal: true
  2. class InstanceFilter
  3. attr_reader :params
  4. def initialize(params)
  5. @params = params
  6. end
  7. def results
  8. scope = Account.remote.by_domain_accounts
  9. params.each do |key, value|
  10. scope.merge!(scope_for(key, value)) if value.present?
  11. end
  12. scope
  13. end
  14. private
  15. def scope_for(key, value)
  16. case key.to_s
  17. when 'domain_name'
  18. Account.matches_domain(value)
  19. else
  20. raise "Unknown filter: #{key}"
  21. end
  22. end
  23. end