RomanSixty / Feed-on-Feeds

FeedOnFeeds is a lightweight server-based RSS feed aggregator and reader
http://feedonfeeds.com/
GNU General Public License v2.0
60 stars 15 forks source link

Add WebSub support #33

Closed fluffy-critter closed 5 years ago

fluffy-critter commented 5 years ago

This update adds support for WebSub (formerly PubSubHubBub) to Feed-On-Feeds. If FoF detects a WebSub hub in a feed, it will register its callback handler with it, and use that to get immediate updates when a post goes live. This does not prevent it from polling a feed for updates down the road, though; it simply uses the notification as a fast-track for receiving an update.

If the originating feed's hub changes then it will be updated at the next poll. The polling interval will be based on the last push time, so frequently-updating feeds will essentially operate as push-only.

At poll time it will also update the WebSub subscription if it's getting ready for renewal. Currently it does this if the subscription lease time is below 10% of its original duration.

If this is running on localhost or behind a firewall it does generate a small amount of excess traffic to the hub but the subscription never activates.

Also, it can only form the callback URL if the update is happening from a web request. The typical use case is a cron job that looks like:

* * * * * curl http://example.com/fof/update-quiet.php

but if it's instead being updated with e.g.

* * * * * php /path/to/update-quiet.php

then WebSub subscriptions won't work. (But this is not a supported configuration so this shouldn't be an issue.)