You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
973 B

  1. # frozen_string_literal: true
  2. class Pubsubhubbub::DistributionWorker
  3. include Sidekiq::Worker
  4. sidekiq_options queue: 'push'
  5. def perform(stream_entry_id)
  6. stream_entry = StreamEntry.find(stream_entry_id)
  7. return if stream_entry.hidden?
  8. account = stream_entry.account
  9. renderer = AccountsController.renderer.new(method: 'get', http_host: Rails.configuration.x.local_domain, https: Rails.configuration.x.use_https)
  10. payload = renderer.render(:show, assigns: { account: account, entries: [stream_entry] }, formats: [:atom])
  11. # domains = account.followers_domains
  12. Subscription.where(account: account).active.select('id, callback_url').find_each do |subscription|
  13. host = Addressable::URI.parse(subscription.callback_url).host
  14. next if DomainBlock.blocked?(host) # || !domains.include?(host)
  15. Pubsubhubbub::DeliveryWorker.perform_async(subscription.id, payload)
  16. end
  17. rescue ActiveRecord::RecordNotFound
  18. true
  19. end
  20. end