thread_resolve_worker.rb 785 B

12345678910111213141516171819202122232425
  1. # frozen_string_literal: true
  2. class ThreadResolveWorker
  3. include Sidekiq::Worker
  4. include ExponentialBackoff
  5. sidekiq_options queue: 'pull', retry: 3
  6. def perform(child_status_id, parent_url, options = {})
  7. child_status = Status.find(child_status_id)
  8. return if child_status.in_reply_to_id.present?
  9. parent_status = ActivityPub::TagManager.instance.uri_to_resource(parent_url, Status)
  10. parent_status ||= FetchRemoteStatusService.new.call(parent_url, **options.deep_symbolize_keys)
  11. return if parent_status.nil?
  12. child_status.thread = parent_status
  13. child_status.save!
  14. DistributionWorker.perform_async(child_status_id, { 'skip_notifications' => true }) if child_status.within_realtime_window?
  15. rescue ActiveRecord::RecordNotFound
  16. true
  17. end
  18. end