app/controllers/feeds_controller.rb
def webhook_subscribe
    # verify the string parameters
    if params['hub.mode'] == 'subscribe' &&
       params['hub.topic'] == @feed.url &&
       params['hub.challenge'].present?

      @feed.status = 'subscription_requested' # 17 mins
      if params['hub.lease_seconds'].present? && params['hub.lease_seconds'].to_i > 0
        @feed.expiration_date = DateTime.now + Rational(params['hub.lease_seconds'].to_i, 86_400)
        unless @feed.save
          # log error
          logger.error "FEED SAVE TO DB ERROR:#{@feed.inspect}"
        end
      end

      render status: 200, plain: params['hub.challenge']
    else
      render status: 422, plain: 'Invalid parameters'
    end
  end
# GET PubSubHubbub callback after you subscribe
GET PubSubHubbub callback after you subscribe
GET PubSubHubbub callback after you subscribe
def webhook_subscribe
    if params['hub.mode'] == 'subscribe' &&
       params['hub.topic'] == @feed.url &&
       params['hub.challenge'].present?
      @feed.status = 'subscription_requested' 
      if params['hub.lease_seconds'].present? && params['hub.lease_seconds'].to_i > 0
        @feed.expiration_date = DateTime.now + Rational(params['hub.lease_seconds'].to_i, 86_400)
        unless @feed.save
          logger.error "FEED SAVE TO DB ERROR:#{@feed.inspect}"
        end
      end
      render status: 200, plain: params['hub.challenge']
    else
      render status: 422, plain: 'Invalid parameters'
    end
  end
def webhook_subscribe if params [ 'hub.mode' ] == 'subscribe' && params [ 'hub.topic' ] == @feed . url && params [ 'hub.challenge' ] . present? @feed . status = 'subscription_requested' if params [ 'hub.lease_seconds' ] . present? && params [ 'hub.lease_seconds' ] . to_i > 0 @feed . expiration_date = DateTime . now + Rational ( params [ 'hub.lease_seconds' ] . to_i , 86_400 ) unless @feed . save logger . error "FEED SAVE TO DB ERROR:#{@feed.inspect}" end end render status : 200 , plain : params [ 'hub.challenge' ] else render status : 422 , plain : 'Invalid parameters' end end
GET PubSubHubbub callback after you subscribe
GET PubSubHubbub callback after you subscribe
# verify the string parameters # 17 mins # log error