Skip to content
Snippets Groups Projects
Commit 85b8625e authored by Aya Morisawa's avatar Aya Morisawa
Browse files

Clean up

parent d731acfd
No related branches found
No related tags found
No related merge requests found
......@@ -16,39 +16,38 @@ import event from '../../../event';
* @return {Promise<object>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>
{
const notificationId = params.notification;
if (notificationId === undefined || notificationId === null) {
return rej('notification is required');
}
// Get notifcation
const notification = await Notification
.findOne({
_id: new mongo.ObjectID(notificationId),
i: user._id
});
new Promise(async (res, rej) => {
const notificationId = params.notification;
if (notificationId === undefined || notificationId === null) {
return rej('notification is required');
}
if (notification === null) {
return rej('notification-not-found');
}
// Get notifcation
const notification = await Notification
.findOne({
_id: new mongo.ObjectID(notificationId),
i: user._id
});
// Update
notification.is_read = true;
Notification.update({ _id: notification._id }, {
$set: {
is_read: true
if (notification === null) {
return rej('notification-not-found');
}
});
// Response
res();
// Update
notification.is_read = true;
Notification.update({ _id: notification._id }, {
$set: {
is_read: true
}
});
// Response
res();
// Serialize
const notificationObj = await serialize(notification);
// Serialize
const notificationObj = await serialize(notification);
// Publish read_notification event
event(user._id, 'read_notification', notificationObj);
});
// Publish read_notification event
event(user._id, 'read_notification', notificationObj);
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment