about summary refs log tree commit diff
path: root/app/workers/reblog_status_worker.rb
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-08-07 01:08:07 -0500
committermultiple creatures <dev@multiple-creature.party>2019-08-07 01:08:34 -0500
commitef04f3879ac3bd7ec6dddd6cb843c8cdb79a1175 (patch)
tree719373d32c084e20d878e9de13a034946c5663b3 /app/workers/reblog_status_worker.rb
parenta8475313b8e81f1e91ee446599a9b7b78716f30c (diff)
add option to automatically space out boosts over configurable random intervals
Diffstat (limited to 'app/workers/reblog_status_worker.rb')
-rw-r--r--app/workers/reblog_status_worker.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/app/workers/reblog_status_worker.rb b/app/workers/reblog_status_worker.rb
new file mode 100644
index 000000000..c0b2153b2
--- /dev/null
+++ b/app/workers/reblog_status_worker.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class ReblogStatusWorker
+  include Sidekiq::Worker
+
+  sidekiq_options unique: :until_executed
+
+  def perform(account_id, status_id, reblog_params = {})
+    account = Account.find(account_id)
+    status = Status.find(status_id)
+    return false if status.destroyed?
+    ReblogService.new.call(account, status, reblog_params.symbolize_keys)
+    true
+  rescue ActiveRecord::RecordNotFound, ActiveRecord::RecordInvalid
+    true
+  end
+end