Follow linter
This commit is contained in:
parent
4e3d617797
commit
3c1b92baa1
70 changed files with 514 additions and 780 deletions
|
|
@ -1,5 +1,3 @@
|
|||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
|
|
@ -15,36 +13,35 @@ import event from '../../event';
|
|||
* @param {any} user
|
||||
* @return {Promise<any>}
|
||||
*/
|
||||
module.exports = (params, user) =>
|
||||
new Promise(async (res, rej) => {
|
||||
const [notificationId, notificationIdErr] = it(params.notification_id).expect.id().required().qed();
|
||||
if (notificationIdErr) return rej('invalid notification_id param');
|
||||
module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||
const [notificationId, notificationIdErr] = it(params.notification_id).expect.id().required().qed();
|
||||
if (notificationIdErr) return rej('invalid notification_id param');
|
||||
|
||||
// Get notification
|
||||
const notification = await Notification
|
||||
.findOne({
|
||||
_id: notificationId,
|
||||
i: user._id
|
||||
});
|
||||
|
||||
if (notification === null) {
|
||||
return rej('notification-not-found');
|
||||
}
|
||||
|
||||
// Update
|
||||
notification.is_read = true;
|
||||
Notification.update({ _id: notification._id }, {
|
||||
$set: {
|
||||
is_read: true
|
||||
}
|
||||
// Get notification
|
||||
const notification = await Notification
|
||||
.findOne({
|
||||
_id: notificationId,
|
||||
i: user._id
|
||||
});
|
||||
|
||||
// Response
|
||||
res();
|
||||
if (notification === null) {
|
||||
return rej('notification-not-found');
|
||||
}
|
||||
|
||||
// Serialize
|
||||
const notificationObj = await serialize(notification);
|
||||
|
||||
// Publish read_notification event
|
||||
event(user._id, 'read_notification', notificationObj);
|
||||
// Update
|
||||
notification.is_read = true;
|
||||
Notification.update({ _id: notification._id }, {
|
||||
$set: {
|
||||
is_read: true
|
||||
}
|
||||
});
|
||||
|
||||
// Response
|
||||
res();
|
||||
|
||||
// Serialize
|
||||
const notificationObj = await serialize(notification);
|
||||
|
||||
// Publish read_notification event
|
||||
event(user._id, 'read_notification', notificationObj);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue