superfeedr / superfeedr-engine

A Superfeedr engine for Ruby on Rails. Handles notifications for you.
https://rubygems.org/gems/superfeedr_engine
MIT License
11 stars 10 forks source link

Bug in the Engine routes: POST instead of GET (or vice versa) #4

Closed collimarco closed 8 years ago

collimarco commented 8 years ago

In my controller:

body, ok = SuperfeedrEngine::Engine.subscribe(@feed, {retrieve: true, sync: true})

I need sync: true because is the only way I have found to validate the url/feed inserted by the user.

This triggers a sync request from Superfeedr to my service, however that request always fails. From my logs:

Started GET "/superfeedr_engine/30?hub.mode=subscribe&hub.topic=http%3A%2F%2Fexamplexyz.wordpress.com%2Ffeed&hub.challenge=lnpw4yj5rk9&hub.lease_seconds=315360000" for 198.58.102.117 at 2016-07-18 12:54:28 +0200 ActionController::RoutingError (No route matches [GET] "/superfeedr_engine/30"): ...

Indeed routes in your Engine are defined as follows:

Routes for SuperfeedrEngine::Engine:
  root GET  /                   superfeedr_engine/pubsubhubbub#index
notify POST /:feed_id(.:format) superfeedr_engine/pubsubhubbub#notify

As you can see the Engine expects a POST while your servers are actually triggering a GET request.

Can you fix this?

collimarco commented 8 years ago

Ok, I've found out that the GET request is for the challenge (as described here: https://blog.superfeedr.com/pubsubhubbub/api/getting-started-with-pubsubhubbub/).

Currently I have made a patch by adding a custom method in routes:

get "#{SuperfeedrEngine::Engine.base_path}:feed_id" => 'feeds#superfeedr_challenge'

However I think that the Rails Engine MUST manage that request by itself.

collimarco commented 8 years ago

I'm making a mess. sync: true is to validate the "intent" to subscribe, it doesn't validate the feed.