diff --git a/api/friends/share.js b/api/friends/share.js index b427da2..1f6c03e 100644 --- a/api/friends/share.js +++ b/api/friends/share.js @@ -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 { diff --git a/app.js b/app.js index 6bb18d7..09fb1a6 100644 --- a/app.js +++ b/app.js @@ -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) { diff --git a/package.json b/package.json index a15e27b..8c76dda 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/routes/api.js b/routes/api.js index 67a8554..b8f4c0d 100644 --- a/routes/api.js +++ b/routes/api.js @@ -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 @@ -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) { diff --git a/routes/web.js b/routes/web.js index 551189c..cfc8f01 100644 --- a/routes/web.js +++ b/routes/web.js @@ -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); diff --git a/test/api-legacy-test.js b/test/api-legacy-test.js index aacf117..e9b3526 100644 --- a/test/api-legacy-test.js +++ b/test/api-legacy-test.js @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); diff --git a/test/api-test.js b/test/api-test.js index c6698a8..dcee531 100644 --- a/test/api-test.js +++ b/test/api-test.js @@ -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); @@ -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); @@ -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); @@ -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); @@ -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);