Class: Pubsubhubbub::FetchTopicJob

Inherits:
ApplicationJob show all
Includes:
Utils
Defined in:
app/jobs/pubsubhubbub/fetch_topic_job.rb

Instance Method Summary collapse

Methods included from Utils

#http_client

Instance Method Details

#perform(hub_url, url) ⇒ Object


8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/jobs/pubsubhubbub/fetch_topic_job.rb', line 8

def perform(hub_url, url)
  return unless Subscription.where(topic: url).active.any?

  current_payload = if Pubsubhubbub.render_topic.is_a?(Proc)
                      Pubsubhubbub.render_topic.call(url)
                    else
                      http_client.get(url).body.to_s
                    end

  Subscription.where(topic: url).active.find_each do |subscription|
    DeliverPayloadJob.perform_later(hub_url, subscription.id, current_payload)
  end
end