logo

mastofe

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

distribution_worker.rb (857B)


  1. # frozen_string_literal: true
  2. class Pubsubhubbub::DistributionWorker
  3. include Sidekiq::Worker
  4. sidekiq_options queue: 'push'
  5. def perform(stream_entry_ids)
  6. stream_entries = StreamEntry.where(id: stream_entry_ids).includes(:status).reject { |e| e.status.nil? || e.status.hidden? }
  7. return if stream_entries.empty?
  8. @account = stream_entries.first.account
  9. @subscriptions = active_subscriptions.to_a
  10. distribute_public!(stream_entries)
  11. end
  12. private
  13. def distribute_public!(stream_entries)
  14. @payload = OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.feed(@account, stream_entries))
  15. Pubsubhubbub::DeliveryWorker.push_bulk(@subscriptions) do |subscription_id|
  16. [subscription_id, @payload]
  17. end
  18. end
  19. def active_subscriptions
  20. Subscription.where(account: @account).active.pluck(:id)
  21. end
  22. end