Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

API route for making all as read.

  • Loading branch information...
commit 5a21f3812cf53ce26b2c3be084692538c70fbb17 1 parent 2ce5443
@brianloveswords brianloveswords authored
Showing with 27 additions and 1 deletion.
  1. +3 −0  app.js
  2. +24 −1 routes/api.js
View
3  app.js
@@ -117,4 +117,7 @@ app.get('/v:apiVersion/user', api.user)
// api for crediting behavior
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;
View
25 routes/api.js
@@ -1,5 +1,6 @@
var Badge = require('../models/badge');
var User = require('../models/user');
+var BadgeInstance = require('../models/badge-instance');
var util = require('../lib/util');
/**
@@ -81,7 +82,29 @@ exports.credit = function credit(req, res) {
};
return obj;
}, {});
-
+
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' });
+ });
+};
Please sign in to comment.
Something went wrong with that request. Please try again.