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'; ...@@ -16,39 +16,38 @@ import event from '../../../event';
* @return {Promise<object>} * @return {Promise<object>}
*/ */
module.exports = (params, user) => module.exports = (params, user) =>
new Promise(async (res, rej) => new Promise(async (res, rej) => {
{ const notificationId = params.notification;
const notificationId = params.notification;
if (notificationId === undefined || notificationId === null) {
if (notificationId === undefined || notificationId === null) { return rej('notification is required');
return rej('notification is required'); }
}
// Get notifcation
const notification = await Notification
.findOne({
_id: new mongo.ObjectID(notificationId),
i: user._id
});
if (notification === null) { // Get notifcation
return rej('notification-not-found'); const notification = await Notification
} .findOne({
_id: new mongo.ObjectID(notificationId),
i: user._id
});
// Update if (notification === null) {
notification.is_read = true; return rej('notification-not-found');
Notification.update({ _id: notification._id }, {
$set: {
is_read: true
} }
});
// Response // Update
res(); notification.is_read = true;
Notification.update({ _id: notification._id }, {
$set: {
is_read: true
}
});
// Response
res();
// Serialize // Serialize
const notificationObj = await serialize(notification); const notificationObj = await serialize(notification);
// Publish read_notification event // Publish read_notification event
event(user._id, 'read_notification', notificationObj); 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