about summary refs log tree commit diff
path: root/app/lib
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2021-04-17 14:55:46 +0200
committerGitHub <noreply@github.com>2021-04-17 14:55:46 +0200
commit6d6000f61f7f611358a45efb3c557eb1e0a7e005 (patch)
treef6b31cd2e1fc3f0c8bb506a8221d2d2b4363ccfd /app/lib
parent480d7c9478a9be3ac668b21402a269db41b10b18 (diff)
Fix remote reporters not receiving suspend/unsuspend activities (#16050)
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/account_reach_finder.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/app/lib/account_reach_finder.rb b/app/lib/account_reach_finder.rb
new file mode 100644
index 000000000..706ce8c1f
--- /dev/null
+++ b/app/lib/account_reach_finder.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+class AccountReachFinder
+  def initialize(account)
+    @account = account
+  end
+
+  def inboxes
+    (followers_inboxes + reporters_inboxes + relay_inboxes).uniq
+  end
+
+  private
+
+  def followers_inboxes
+    @account.followers.inboxes
+  end
+
+  def reporters_inboxes
+    Account.where(id: @account.targeted_reports.select(:account_id)).inboxes
+  end
+
+  def relay_inboxes
+    Relay.enabled.pluck(:inbox_url)
+  end
+end