about summary refs log tree commit diff
path: root/app/models/instance_filter.rb
diff options
context:
space:
mode:
authorTakeshi Umeda <noel.yoshiba@gmail.com>2021-05-06 06:39:02 +0900
committerGitHub <noreply@github.com>2021-05-05 23:39:02 +0200
commit7cb34b32f8bc925b56c79dbcf053671f93f2eb42 (patch)
treeb05d123350c4af203a6009418b1bfc7056820b27 /app/models/instance_filter.rb
parentd9ae3db8d5543cf0b7fa44186c191c9bb2472d23 (diff)
Add management of delivery availability in Federation settings (#15771)
* Add management of delivery availavility in Federation settings

* fix translate

* Remove useless object creation

* Fix DeepSource issue

* Add shortcut for all

* Fix DeepSource(skipcq)

* Change 'remove' to 'clear'

* Fix style

* Change class method name (exhausted_deliveries_key_by)
Diffstat (limited to 'app/models/instance_filter.rb')
-rw-r--r--app/models/instance_filter.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/app/models/instance_filter.rb b/app/models/instance_filter.rb
index 0598d8fea..9e533c4aa 100644
--- a/app/models/instance_filter.rb
+++ b/app/models/instance_filter.rb
@@ -4,6 +4,8 @@ class InstanceFilter
   KEYS = %i(
     limited
     by_domain
+    warning
+    unavailable
   ).freeze
 
   attr_reader :params
@@ -13,7 +15,7 @@ class InstanceFilter
   end
 
   def results
-    scope = Instance.includes(:domain_block, :domain_allow).order(accounts_count: :desc)
+    scope = Instance.includes(:domain_block, :domain_allow, :unavailable_domain).order(accounts_count: :desc)
 
     params.each do |key, value|
       scope.merge!(scope_for(key, value.to_s.strip)) if value.present?
@@ -32,6 +34,10 @@ class InstanceFilter
       Instance.joins(:domain_allow).reorder(Arel.sql('domain_allows.id desc'))
     when 'by_domain'
       Instance.matches_domain(value)
+    when 'warning'
+      Instance.where(domain: DeliveryFailureTracker.warning_domains)
+    when 'unavailable'
+      Instance.joins(:unavailable_domain)
     else
       raise "Unknown filter: #{key}"
     end