diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2017-03-03 08:24:48 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2017-03-03 08:24:48 +0900 |
| commit | 2a9cba25a89b5cf2394a22696ee0fb67140076a9 (patch) | |
| tree | 449eedac92632e4d9eed507b6186762e1f7b6e48 /src/api/endpoints/notifications/mark_as_read.js | |
| parent | wip (diff) | |
| download | misskey-2a9cba25a89b5cf2394a22696ee0fb67140076a9.tar.gz misskey-2a9cba25a89b5cf2394a22696ee0fb67140076a9.tar.bz2 misskey-2a9cba25a89b5cf2394a22696ee0fb67140076a9.zip | |
wip
Diffstat (limited to 'src/api/endpoints/notifications/mark_as_read.js')
| -rw-r--r-- | src/api/endpoints/notifications/mark_as_read.js | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/src/api/endpoints/notifications/mark_as_read.js b/src/api/endpoints/notifications/mark_as_read.js deleted file mode 100644 index 9c8a5ee64b..0000000000 --- a/src/api/endpoints/notifications/mark_as_read.js +++ /dev/null @@ -1,53 +0,0 @@ -'use strict'; - -/** - * Module dependencies - */ -import * as mongo from 'mongodb'; -import Notification from '../../../models/notification'; -import serialize from '../../../serializers/notification'; -import event from '../../../event'; - -/** - * Mark as read a notification - * - * @param {any} params - * @param {any} user - * @return {Promise<any>} - */ -module.exports = (params, user) => - new Promise(async (res, rej) => { - const notificationId = params.notification; - - if (notificationId === undefined || notificationId === null) { - return rej('notification is required'); - } - - // Get notification - const notification = await Notification - .findOne({ - _id: new mongo.ObjectID(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 - } - }); - - // Response - res(); - - // Serialize - const notificationObj = await serialize(notification); - - // Publish read_notification event - event(user._id, 'read_notification', notificationObj); - }); |