Skip to content
This repository has been archived by the owner on Jan 14, 2020. It is now read-only.

Commit

Permalink
API route for making all as read.
Browse files Browse the repository at this point in the history
  • Loading branch information
brianloveswords committed Oct 16, 2012
1 parent 2ce5443 commit 5a21f38
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app.js
Expand Up @@ -117,4 +117,7 @@ app.get('/v:apiVersion/user', api.user)
// api for crediting behavior // api for crediting behavior
app.post('/v:apiVersion/user/behavior/:behavior/credit', api.credit); app.post('/v:apiVersion/user/behavior/:behavior/credit', api.credit);


// api for crediting behavior
app.post('/v:apiVersion/user/mark-all-as-read', api.markAllAsRead);

module.exports = app; module.exports = app;
25 changes: 24 additions & 1 deletion routes/api.js
@@ -1,5 +1,6 @@
var Badge = require('../models/badge'); var Badge = require('../models/badge');
var User = require('../models/user'); var User = require('../models/user');
var BadgeInstance = require('../models/badge-instance');
var util = require('../lib/util'); var util = require('../lib/util');


/** /**
Expand Down Expand Up @@ -81,7 +82,29 @@ exports.credit = function credit(req, res) {
}; };
return obj; return obj;
}, {}); }, {});

res.send(statusCode, result); res.send(statusCode, result);
}); });
}; };


/**
* Mark all user badges as read.
*/

exports.markAllAsRead = function markAllAsRead(req, res) {
var form = req.body;

if (!form.email)
return res.send(400, {
status: 'missing-parameter',
parameter: 'email',
message: 'You need to pass in a valid email address'
});

BadgeInstance.markAllAsRead(form.email, function (err) {
if (err)
return res.send(500, { status: 'error', error: err });
return res.send(200, { status: 'ok' });
});
};

0 comments on commit 5a21f38

Please sign in to comment.