From 5d09b7e38b42f19530d51feeeae0e57ad4320351 Mon Sep 17 00:00:00 2001 From: Aya Morisawa Date: Fri, 20 Jul 2018 14:16:02 +0900 Subject: mark as read all -> mark all as read Close #855 --- .../endpoints/notifications/mark_all_as_read.ts | 44 ++++++++++++++++++++++ .../endpoints/notifications/mark_as_read_all.ts | 44 ---------------------- 2 files changed, 44 insertions(+), 44 deletions(-) create mode 100644 src/server/api/endpoints/notifications/mark_all_as_read.ts delete mode 100644 src/server/api/endpoints/notifications/mark_as_read_all.ts (limited to 'src/server/api/endpoints/notifications') diff --git a/src/server/api/endpoints/notifications/mark_all_as_read.ts b/src/server/api/endpoints/notifications/mark_all_as_read.ts new file mode 100644 index 0000000000..91319d0553 --- /dev/null +++ b/src/server/api/endpoints/notifications/mark_all_as_read.ts @@ -0,0 +1,44 @@ +import Notification from '../../../../models/notification'; +import event from '../../../../stream'; +import User, { ILocalUser } from '../../../../models/user'; + +export const meta = { + desc: { + ja: '全ての通知を既読にします。', + en: 'Mark all notifications as read.' + }, + + requireCredential: true, + + kind: 'notification-write' +}; + +/** + * Mark all notifications as read + */ +export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { + // Update documents + await Notification.update({ + notifieeId: user._id, + isRead: false + }, { + $set: { + isRead: true + } + }, { + multi: true + }); + + // Response + res(); + + // Update flag + User.update({ _id: user._id }, { + $set: { + hasUnreadNotification: false + } + }); + + // 全ての通知を読みましたよというイベントを発行 + event(user._id, 'read_all_notifications'); +}); diff --git a/src/server/api/endpoints/notifications/mark_as_read_all.ts b/src/server/api/endpoints/notifications/mark_as_read_all.ts deleted file mode 100644 index 7cf4cd16e9..0000000000 --- a/src/server/api/endpoints/notifications/mark_as_read_all.ts +++ /dev/null @@ -1,44 +0,0 @@ -import Notification from '../../../../models/notification'; -import event from '../../../../stream'; -import User, { ILocalUser } from '../../../../models/user'; - -export const meta = { - desc: { - ja: '全ての通知を既読にします。', - en: 'Mark as read all notifications.' - }, - - requireCredential: true, - - kind: 'notification-write' -}; - -/** - * Mark as read all notifications - */ -export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { - // Update documents - await Notification.update({ - notifieeId: user._id, - isRead: false - }, { - $set: { - isRead: true - } - }, { - multi: true - }); - - // Response - res(); - - // Update flag - User.update({ _id: user._id }, { - $set: { - hasUnreadNotification: false - } - }); - - // 全ての通知を読みましたよというイベントを発行 - event(user._id, 'read_all_notifications'); -}); -- cgit v1.2.3-freya