Last night, I was thinking about creating something which can notify you when someone forks or start watching your repositories even if you are offline. So I had a look to the Repository Hook API and just found that almost all the hooks are targeting push ie you can use tens of connector to be notified on the system of your choice only when a push occurs on your repository. Let’s have a look to the event API but this is not a really good idea, I already use it in QuickHub to notify about activities and it’s just about polling for changes.
So what? Hopefully, there is one alternative: The pubsubhubbub API. According to the GitHub documentation, one can subscribe to any event type using this API. You just have to tell which one on which repository and give it a callback. Giving it a callback is just what we want: Having something which runs online and which can receive events and notify me even if I am offline… Here we go for some Web development with the PlayFramework and Heroku for hosting, here is mygithubnotifier.
mygithubnotifier uses the GitHub Java API from Eclipse. Even if JSON is easy to parse, having it already done is faster. The application retrieves all your personal repositories and provides the user the choice to subscribe/unsubscribe using the pubsubhubbub protocol. This protocol is really simple to use: One endpoint and three parameters are enough. If I want to subscribe to forks on my repository, I just need an authenticated HTTP call like to
with some parameters for defining the topic (repository), the mode (subscribe/unsubscribe), the event type (fork, watch, …) and the callback URL which will be some REST endpoint exposed by the Play application. The application will send an email every time someone forks one of your repository if you subscribed to this event before.
The code is really simple and will not be detailed here. You can get it from GitHub at chamerling/mygithubnotifier. I assume that deploying the Play application to Heroku is as easy as described in their documentation. You just have to configure the application by specifying the right email and GitHub properties as described in the README.md.