You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
789 B

  1. # frozen_string_literal: true
  2. class PublishScheduledStatusWorker
  3. include Sidekiq::Worker
  4. def perform(scheduled_status_id)
  5. scheduled_status = ScheduledStatus.find(scheduled_status_id)
  6. scheduled_status.destroy!
  7. PostStatusService.new.call(
  8. scheduled_status.account,
  9. options_with_objects(scheduled_status.params.with_indifferent_access)
  10. )
  11. rescue ActiveRecord::RecordNotFound, ActiveRecord::RecordInvalid
  12. true
  13. end
  14. def options_with_objects(options)
  15. options.tap do |options_hash|
  16. options_hash[:application] = Doorkeeper::Application.find(options_hash.delete(:application_id)) if options[:application_id]
  17. options_hash[:thread] = Status.find(options_hash.delete(:in_reply_to_id)) if options_hash[:in_reply_to_id]
  18. end
  19. end
  20. end