Posted on 22/01/2017 at 4:00 PM by The Vibe.
Web Software Design Development Documentation Ruby Ruby on Rails
Any developer would most probably be familiar with GitHub & its notification system. Currently, GitHub provides email notifications to watched repositories & mentions. However, GitHub fails to provide a similar email notification when someone follows / unfollows you. This GitHub App solves this issue by mailing the users on a daily basis about any new followers / unfollowers - to the email ID which is associated with their GitHub account. With just a click of a button here, you can activate this service.
Working with the GitHub API OAuth without using any external gem like
Devise can become messy and
even difficult at times. However, it was
this guide that played the
role of saviour when I was stuck. Following the above guide, I was able to
exchange the code
, client_id
and client_secret
for an access_token
.
An access_token
is the parameter through which my application can access a
user's public information such as name
, email
, github handle
,
followers list
, etc. However, reloading the callback_uri
made the
website throw an error as a code
when exchanged once can't be used again.
Hence, I found out that I had to maintain session
variables & redirect
properly so that the accesstoken won't be visible in the `callbackuri`.
Once the access_token
was received, I had to store it into the database.
Before storing in the batabase, I also had to make sure that no two
access_token
s point to the same user account - as this case would lead
to multiple emails being sent to that user on that day. Then, the cron job
logs into each user in the database and mails them their respective
notification emails if there are any new followers / unfollowers.
So - that's how I built it, folks. Comment below, your thoughts on this application. If you liked this project, do star the repository & follow me on github.