logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

update_distribution_worker.rb (652B)


  1. # frozen_string_literal: true
  2. class ActivityPub::UpdateDistributionWorker
  3. include Sidekiq::Worker
  4. sidekiq_options queue: 'push'
  5. def perform(account_id)
  6. @account = Account.find(account_id)
  7. ActivityPub::DeliveryWorker.push_bulk(inboxes) do |inbox_url|
  8. [payload, @account.id, inbox_url]
  9. end
  10. rescue ActiveRecord::RecordNotFound
  11. true
  12. end
  13. private
  14. def inboxes
  15. @inboxes ||= @account.followers.inboxes
  16. end
  17. def payload
  18. @payload ||= ActiveModelSerializers::SerializableResource.new(
  19. @account,
  20. serializer: ActivityPub::UpdateSerializer,
  21. adapter: ActivityPub::Adapter
  22. ).to_json
  23. end
  24. end