distribution_worker.rb 792 B

1234567891011121314151617181920212223242526272829303132
  1. # frozen_string_literal: true
  2. class ActivityPub::DistributionWorker < ActivityPub::RawDistributionWorker
  3. # Distribute a new status or an edit of a status to all the places
  4. # where the status is supposed to go or where it was interacted with
  5. def perform(status_id)
  6. @status = Status.find(status_id)
  7. @account = @status.account
  8. distribute!
  9. rescue ActiveRecord::RecordNotFound
  10. true
  11. end
  12. protected
  13. def inboxes
  14. @inboxes ||= StatusReachFinder.new(@status).inboxes
  15. end
  16. def payload
  17. @payload ||= Oj.dump(serialize_payload(activity, ActivityPub::ActivitySerializer, signer: @account))
  18. end
  19. def activity
  20. ActivityPub::ActivityPresenter.from_status(@status)
  21. end
  22. def options
  23. { 'synchronize_followers' => @status.private_visibility? }
  24. end
  25. end