notifications: acknowledged can be null

This commit is contained in:
Girish Ramakrishnan
2021-05-29 12:11:28 -07:00
parent 73917e95c9
commit 9e7dd3f397
2 changed files with 81 additions and 2 deletions
+3 -2
View File
@@ -40,9 +40,10 @@ async function list(req, res, next) {
if (req.query.acknowledged && !(req.query.acknowledged === 'true' || req.query.acknowledged === 'false')) return next(new HttpError(400, 'acknowledged must be a true or false'));
const acknowledged = req.query.acknowledged ? req.query.acknowledged === 'true' : false;
let filters = {};
if (req.query.acknowledged) filters.acknowledged = req.query.acknowledged === 'true';
const [error, result] = await safe(notifications.list({ userId: req.user.id, acknowledged }, page, perPage));
const [error, result] = await safe(notifications.list(filters, page, perPage));
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(200, { notifications: result }));
}