notifications: can also mark it as unread
This commit is contained in:
@@ -4,7 +4,7 @@ exports = module.exports = {
|
||||
verifyOwnership,
|
||||
get,
|
||||
list,
|
||||
ack
|
||||
update
|
||||
};
|
||||
|
||||
let assert = require('assert'),
|
||||
@@ -44,17 +44,20 @@ function list(req, res, next) {
|
||||
|
||||
const acknowledged = req.query.acknowledged ? req.query.acknowledged === 'true' : null;
|
||||
|
||||
notifications.listByUserIdPaged(req.user.id, { acknowledged }, page, perPage, function (error, result) {
|
||||
notifications.list({ userId: req.user.id, acknowledged }, page, perPage, function (error, result) {
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(200, { notifications: result }));
|
||||
});
|
||||
}
|
||||
|
||||
function ack(req, res, next) {
|
||||
function update(req, res, next) {
|
||||
assert.strictEqual(typeof req.params.notificationId, 'string');
|
||||
assert.strictEqual(typeof req.body, 'object');
|
||||
|
||||
notifications.ack(req.params.notificationId, function (error) {
|
||||
if (typeof req.body.acknowledged !== 'boolean') return next(new HttpError(400, 'acknowledged must be a booliean'));
|
||||
|
||||
notifications.update(req.params.notificationId, { acknowledged: req.body.acknowledged }, function (error) {
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(204, {}));
|
||||
|
||||
Reference in New Issue
Block a user