Browse Source

replace minTs with timeSpan (in secs) in /v1/notifications

activeAddress
Ivan Socolsky 9 years ago
parent
commit
e7855e1e89
  1. 3
      lib/expressapp.js
  2. 4
      test/expressapp.js

3
lib/expressapp.js

@ -439,8 +439,9 @@ ExpressApp.prototype.start = function(opts, cb) {
router.get('/v1/notifications/', function(req, res) { router.get('/v1/notifications/', function(req, res) {
getServerWithAuth(req, res, function(server) { getServerWithAuth(req, res, function(server) {
var timeSpan = req.query.timeSpan ? Math.min(+req.query.timeSpan || 0, 60) : 60;
var opts = { var opts = {
minTs: Math.max(+req.query.minTs || 0, +Date.now() - (60 * 1000)), minTs: +Date.now() - (timeSpan * 1000),
notificationId: req.query.notificationId, notificationId: req.query.notificationId,
}; };
server.getNotifications(opts, function(err, notifications) { server.getNotifications(opts, function(err, notifications) {

4
test/expressapp.js

@ -127,7 +127,7 @@ describe('ExpressApp', function() {
it('should allow custom minTs within limits', function(done) { it('should allow custom minTs within limits', function(done) {
start(TestExpressApp, function() { start(TestExpressApp, function() {
var requestOptions = { var requestOptions = {
url: testHost + ':' + testPort + config.basePath + '/v1/notifications' + '?minTs=' + (Date.now() - 30000), url: testHost + ':' + testPort + config.basePath + '/v1/notifications' + '?timeSpan=30',
headers: { headers: {
'x-identity': 'identity', 'x-identity': 'identity',
'x-signature': 'signature' 'x-signature': 'signature'
@ -147,7 +147,7 @@ describe('ExpressApp', function() {
it('should limit minTs to 60 seconds', function(done) { it('should limit minTs to 60 seconds', function(done) {
start(TestExpressApp, function() { start(TestExpressApp, function() {
var requestOptions = { var requestOptions = {
url: testHost + ':' + testPort + config.basePath + '/v1/notifications' + '?minTs=' + (Date.now() - 90000), url: testHost + ':' + testPort + config.basePath + '/v1/notifications' + '?timeSpan=90',
headers: { headers: {
'x-identity': 'identity', 'x-identity': 'identity',
'x-signature': 'signature' 'x-signature': 'signature'

Loading…
Cancel
Save