about summary refs log tree commit diff
path: root/app/workers/pubsubhubbub/raw_distribution_worker.rb
blob: 16962a623ce72ad3d3381cec93a0711dbc4dc84a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

class Pubsubhubbub::RawDistributionWorker
  include Sidekiq::Worker

  sidekiq_options queue: 'push'

  def perform(xml, source_account_id)
    @account       = Account.find(source_account_id)
    @subscriptions = active_subscriptions.to_a

    Pubsubhubbub::DeliveryWorker.push_bulk(@subscriptions) do |subscription|
      [subscription.id, xml]
    end
  end

  private

  def active_subscriptions
    Subscription.where(account: @account).active.select('id, callback_url, domain')
  end
end