update_distribution_worker.rb 738 B

1234567891011121314151617181920212223242526
  1. # frozen_string_literal: true
  2. class ActivityPub::UpdateDistributionWorker < ActivityPub::RawDistributionWorker
  3. sidekiq_options queue: 'push', lock: :until_executed, lock_ttl: 1.day.to_i
  4. # Distribute an profile update to servers that might have a copy
  5. # of the account in question
  6. def perform(account_id, options = {})
  7. @options = options.with_indifferent_access
  8. @account = Account.find(account_id)
  9. distribute!
  10. rescue ActiveRecord::RecordNotFound
  11. true
  12. end
  13. protected
  14. def inboxes
  15. @inboxes ||= AccountReachFinder.new(@account).inboxes
  16. end
  17. def payload
  18. @payload ||= Oj.dump(serialize_payload(@account, ActivityPub::UpdateSerializer, signer: @account, sign_with: @options[:sign_with]))
  19. end
  20. end