Skip to content

Commit

Permalink
Receiver for Timetable Share
Browse files Browse the repository at this point in the history
* Fixes #43
* Version bumped to 0.15.20
  • Loading branch information
aneesh-neelam committed Apr 2, 2015
1 parent 3b1a197 commit ba3ef4f
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 14 deletions.
1 change: 1 addition & 0 deletions api/friends/share.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ exports.get = function (app, data, callback) {
delete doc['_id'];
doc.courses.forEach(forEachCourse);
doc.status = status.codes.success;
app.queue.publish(queue.queues.share, {receiver: data.receiver, owner: doc.reg_no});
callback(false, doc);
}
else {
Expand Down
3 changes: 2 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ var amqpUri = process.env.AMQP_URI || 'amqp://localhost';
var queue = jackrabbit(amqpUri);
queue.queues = {
main: 'VITacademics',
mobile: 'mobile'
mobile: 'mobile',
share: 'share'
};
queue.on('connected', function () {
var forEachQueue = function (elt, i, arr) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "VITacademics",
"version": "0.15.16",
"version": "0.15.20",
"description": "VITacademics Backend and Web App",
"homepage": "https://vitacademics-rel.herokuapp.com/",
"bugs": {
Expand Down
4 changes: 4 additions & 0 deletions routes/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,11 @@ router.post('/token', function (req, res) {
router.post('/share', function (req, res) {
var token;
var reg_no;
var receiver;
if (req.body.token) token = req.body.token.toUpperCase();
if (req.body.regno) reg_no = req.body.regno.toUpperCase();
if (req.body.receiver === 'VITacademics Developer/Tester') receiver = req.body.receiver;
else if (req.body.receiver) receiver = req.body.receiver.toUpperCase();
var app = {
db: req.db,
queue: req.queue
Expand All @@ -106,6 +109,7 @@ router.post('/share', function (req, res) {
reg_no: reg_no,
dob: req.body.dob,
token: token,
receiver: receiver,
campus: req.originalUrl.split('/')[3].toLowerCase()
};
var onGet = function (err, response) {
Expand Down
2 changes: 1 addition & 1 deletion routes/web.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ router.get('/status', function (req, res) {
platform: process.platform,
arch: process.arch,
serverStatus: 'OK',
lastUpdated: '1st April 2015',
lastUpdated: '2nd April 2015',
googleAnalyticsToken: googleAnalyticsToken
};
res.render('status', status);
Expand Down
12 changes: 6 additions & 6 deletions test/api-legacy-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var onEach = function (user, i, arr) {

it('Checking if getting captcha image is successful', function (done) {
api.get('/api/' + user.campus + '/login/manual')
.query({'regno': user.reg_no})
.query({regno: user.reg_no})
.expect(200)
.end(function (err, res) {
should.not.exist(err);
Expand All @@ -49,7 +49,7 @@ var onEach = function (user, i, arr) {

it('Checking if auto-login is successful', function (done) {
api.get('/api/' + user.campus + '/login/auto')
.query({'regno': user.reg_no, 'dob': user.dob})
.query({regno: user.reg_no, dob: user.dob})
.expect(200)
.end(function (err, res) {
should.not.exist(err);
Expand All @@ -63,7 +63,7 @@ var onEach = function (user, i, arr) {

it('Checking if first data fetch is successful', function (done) {
api.get('/api/' + user.campus + '/data/first')
.query({'regno': user.reg_no, 'dob': user.dob})
.query({regno: user.reg_no, dob: user.dob})
.expect(200)
.end(function (err, res) {
should.not.exist(err);
Expand All @@ -83,7 +83,7 @@ var onEach = function (user, i, arr) {

it('Checking if data refresh is successful', function (done) {
api.get('/api/' + user.campus + '/data/refresh')
.query({'regno': user.reg_no, 'dob': user.dob})
.query({regno: user.reg_no, dob: user.dob})
.expect(200)
.end(function (err, res) {
should.not.exist(err);
Expand All @@ -101,7 +101,7 @@ var onEach = function (user, i, arr) {

it('Checking if token generation is successful', function (done) {
api.get('/api/' + user.campus + '/friends/regenerate')
.query({'regno': user.reg_no, 'dob': user.dob})
.query({regno: user.reg_no, dob: user.dob})
.expect(200)
.end(function (err, res) {
should.not.exist(err);
Expand All @@ -116,7 +116,7 @@ var onEach = function (user, i, arr) {

it('Checking if share using credentials is successful', function (done) {
api.get('/api/' + user.campus + '/friends/share')
.query({'regno': user.reg_no, 'dob': user.dob})
.query({regno: user.reg_no, dob: user.dob})
.expect(200)
.end(function (err, res) {
should.not.exist(err);
Expand Down
10 changes: 5 additions & 5 deletions test/api-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var onEach = function (user, i, arr) {

it('Checking if login is successful', function (done) {
api.post('/api/v2/' + user.campus + '/login')
.send({'regno': user.reg_no, 'dob': user.dob})
.send({regno: user.reg_no, dob: user.dob})
.expect(200)
.end(function (err, res) {
should.not.exist(err);
Expand All @@ -51,7 +51,7 @@ var onEach = function (user, i, arr) {

it('Checking if fetching/refreshing current semester details is successful', function (done) {
api.post('/api/v2/' + user.campus + '/refresh')
.send({'regno': user.reg_no, 'dob': user.dob})
.send({regno: user.reg_no, dob: user.dob})
.expect(200)
.end(function (err, res) {
should.not.exist(err);
Expand All @@ -70,7 +70,7 @@ var onEach = function (user, i, arr) {

it('Checking if fetching grades is successful', function (done) {
api.post('/api/v2/' + user.campus + '/grades')
.send({'regno': user.reg_no, 'dob': user.dob})
.send({regno: user.reg_no, dob: user.dob})
.expect(200)
.end(function (err, res) {
should.not.exist(err);
Expand All @@ -92,7 +92,7 @@ var onEach = function (user, i, arr) {

it('Checking if token generation is successful', function (done) {
api.post('/api/v2/' + user.campus + '/token')
.send({'regno': user.reg_no, 'dob': user.dob})
.send({regno: user.reg_no, dob: user.dob})
.expect(200)
.end(function (err, res) {
should.not.exist(err);
Expand All @@ -107,7 +107,7 @@ var onEach = function (user, i, arr) {

it('Checking if share using credentials is successful', function (done) {
api.post('/api/v2/' + user.campus + '/share')
.send({'regno': user.reg_no, 'dob': user.dob})
.send({regno: user.reg_no, dob: user.dob, receiver: 'VITacademics Developer/Tester'})
.expect(200)
.end(function (err, res) {
should.not.exist(err);
Expand Down

0 comments on commit ba3ef4f

Please sign in to comment.