about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-12-12 04:33:51 -0600
committermultiple creatures <dev@multiple-creature.party>2019-12-12 04:33:51 -0600
commit114fc3cdd01e7932776a5fd4601451c821aef11d (patch)
tree9473099b6a9f1a9857b5e58f63a3d79deba62679 /app
parent49c7092f7ecd94e417226dad1c53f2e98544b328 (diff)
simplify the asynchronous post worker
Diffstat (limited to 'app')
-rw-r--r--app/workers/post_status_worker.rb14
1 files changed, 5 insertions, 9 deletions
diff --git a/app/workers/post_status_worker.rb b/app/workers/post_status_worker.rb
index 7b44c9a54..82f5e78e9 100644
--- a/app/workers/post_status_worker.rb
+++ b/app/workers/post_status_worker.rb
@@ -3,20 +3,14 @@
 class PostStatusWorker
   include Sidekiq::Worker
 
-  sidekiq_options unique: :until_executed
-
   def perform(status_id, options = {})
     status = Status.find(status_id)
     return false if status.destroyed?
 
-    status.visibility = options[:visibility] if options[:visibility]
-    status.local_only = options[:local_only] if options[:local_only]
-    status.reject_replies = options[:reject_replies] if options[:reject_replies]
-    status.save!
-
-    process_mentions_service.call(status) unless options[:nomentions].present?
+    status.update(options.slice(:visibility, :local_only, :reject_replies).compact)
+    process_mentions_service.call(status, skip_process: true) unless options[:nomentions]
 
-    LinkCrawlWorker.perform_async(status.id) unless options[:nocrawl] || status.spoiler_text?
+    LinkCrawlWorker.perform_async(status.id) unless options[:nocrawl] || status.spoiler_text.present?
     DistributionWorker.perform_async(status.id) unless options[:distribute] == false
 
     unless status.local_only? || options[:distribute] == false || options[:federate] == false
@@ -37,6 +31,8 @@ class PostStatusWorker
     true
   end
 
+  private
+
   def process_mentions_service
     ProcessMentionsService.new
   end