about summary refs log tree commit diff
path: root/app/workers
diff options
context:
space:
mode:
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/activitypub/distribute_poll_update_worker.rb2
-rw-r--r--app/workers/feed_insert_worker.rb6
-rw-r--r--app/workers/reset_account_worker.rb16
-rw-r--r--app/workers/scheduler/feed_cleanup_scheduler.rb5
4 files changed, 28 insertions, 1 deletions
diff --git a/app/workers/activitypub/distribute_poll_update_worker.rb b/app/workers/activitypub/distribute_poll_update_worker.rb
index 25dee4ee2..601075ea6 100644
--- a/app/workers/activitypub/distribute_poll_update_worker.rb
+++ b/app/workers/activitypub/distribute_poll_update_worker.rb
@@ -10,7 +10,7 @@ class ActivityPub::DistributePollUpdateWorker
     @status  = Status.find(status_id)
     @account = @status.account
 
-    return unless @status.preloadable_poll
+    return if @status.preloadable_poll.nil? || @status.local_only?
 
     ActivityPub::DeliveryWorker.push_bulk(inboxes) do |inbox_url|
       [payload, @account.id, inbox_url]
diff --git a/app/workers/feed_insert_worker.rb b/app/workers/feed_insert_worker.rb
index b70c7e389..45e6bb88d 100644
--- a/app/workers/feed_insert_worker.rb
+++ b/app/workers/feed_insert_worker.rb
@@ -13,6 +13,8 @@ class FeedInsertWorker
     when :list
       @list     = List.find(id)
       @follower = @list.account
+    when :direct
+      @account  = Account.find(id)
     end
 
     check_and_insert
@@ -35,6 +37,8 @@ class FeedInsertWorker
       FeedManager.instance.filter?(:home, @status, @follower)
     when :list
       FeedManager.instance.filter?(:list, @status, @list)
+    when :direct
+      FeedManager.instance.filter?(:direct, @status, @account)
     end
   end
 
@@ -50,6 +54,8 @@ class FeedInsertWorker
       FeedManager.instance.push_to_home(@follower, @status)
     when :list
       FeedManager.instance.push_to_list(@list, @status)
+    when :direct
+      FeedManager.instance.push_to_direct(@account, @status)
     end
   end
 
diff --git a/app/workers/reset_account_worker.rb b/app/workers/reset_account_worker.rb
new file mode 100644
index 000000000..f63d8682a
--- /dev/null
+++ b/app/workers/reset_account_worker.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class ResetAccountWorker
+  include Sidekiq::Worker
+
+  def perform(account_id)
+    account = Account.find(account_id)
+    return if account.local?
+
+    account_uri = account.uri
+    SuspendAccountService.new.call(account)
+    ResolveAccountService.new.call(account_uri)
+  rescue ActiveRecord::RecordNotFound
+    true
+  end
+end
diff --git a/app/workers/scheduler/feed_cleanup_scheduler.rb b/app/workers/scheduler/feed_cleanup_scheduler.rb
index 458fe6193..99e3440fe 100644
--- a/app/workers/scheduler/feed_cleanup_scheduler.rb
+++ b/app/workers/scheduler/feed_cleanup_scheduler.rb
@@ -9,6 +9,7 @@ class Scheduler::FeedCleanupScheduler
   def perform
     clean_home_feeds!
     clean_list_feeds!
+    clean_direct_feeds!
   end
 
   private
@@ -21,6 +22,10 @@ class Scheduler::FeedCleanupScheduler
     clean_feeds!(inactive_list_ids, :list)
   end
 
+  def clean_direct_feeds!
+    clean_feeds!(inactive_account_ids, :direct)
+  end
+
   def clean_feeds!(ids, type)
     reblogged_id_sets = {}