summaryrefslogtreecommitdiffstats
path: root/app/workers/publish_scheduled_status_worker.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2019-01-05 12:43:28 +0100
committerGitHub <noreply@github.com>2019-01-05 12:43:28 +0100
commita49d43d1121ac10f96d5a9cbf78112c707e7a59e (patch)
treeee311cf3d68d695f6cc6c69ce9e1b01c6ad4aeb4 /app/workers/publish_scheduled_status_worker.rb
parentb17b2f25acc4d0cd4284835f28364451cb2fcd88 (diff)
Add scheduled statuses (#9706)
Fix #340
Diffstat (limited to 'app/workers/publish_scheduled_status_worker.rb')
-rw-r--r--app/workers/publish_scheduled_status_worker.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/app/workers/publish_scheduled_status_worker.rb b/app/workers/publish_scheduled_status_worker.rb
new file mode 100644
index 00000000000..298a13001e2
--- /dev/null
+++ b/app/workers/publish_scheduled_status_worker.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class PublishScheduledStatusWorker
+ include Sidekiq::Worker
+
+ def perform(scheduled_status_id)
+ scheduled_status = ScheduledStatus.find(scheduled_status_id)
+ scheduled_status.destroy!
+
+ PostStatusService.new.call(
+ scheduled_status.account,
+ options_with_objects(scheduled_status.params.with_indifferent_access)
+ )
+ rescue ActiveRecord::RecordNotFound, ActiveRecord::RecordInvalid
+ true
+ end
+
+ def options_with_objects(options)
+ options.tap do |options_hash|
+ options_hash[:application] = Doorkeeper::Application.find(options_hash.delete(:application_id)) if options[:application_id]
+ options_hash[:thread] = Status.find(options_hash.delete(:in_reply_to_status_id)) if options_hash[:in_reply_to_status_id]
+ end
+ end
+end