From f4ae9391248d9ba366210be215681537ce9ecb49 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 24 Feb 2019 17:57:49 +0900 Subject: ハイフンに統一 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../endpoints/notifications/mark-all-as-read.ts | 41 ++++++++++++++++++++++ .../endpoints/notifications/mark_all_as_read.ts | 41 ---------------------- 2 files changed, 41 insertions(+), 41 deletions(-) create mode 100644 src/server/api/endpoints/notifications/mark-all-as-read.ts delete mode 100644 src/server/api/endpoints/notifications/mark_all_as_read.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..e5df648285 --- /dev/null +++ b/src/server/api/endpoints/notifications/mark-all-as-read.ts @@ -0,0 +1,41 @@ +import Notification from '../../../../models/notification'; +import { publishMainStream } from '../../../../services/stream'; +import User from '../../../../models/user'; +import define from '../../define'; + +export const meta = { + desc: { + 'ja-JP': '全ての通知を既読にします。', + 'en-US': 'Mark all notifications as read.' + }, + + tags: ['notifications', 'account'], + + requireCredential: true, + + kind: 'notification-write' +}; + +export default define(meta, async (ps, user) => { + // Update documents + await Notification.update({ + notifieeId: user._id, + isRead: false + }, { + $set: { + isRead: true + } + }, { + multi: true + }); + + // Update flag + User.update({ _id: user._id }, { + $set: { + hasUnreadNotification: false + } + }); + + // 全ての通知を読みましたよというイベントを発行 + publishMainStream(user._id, 'readAllNotifications'); +}); diff --git a/src/server/api/endpoints/notifications/mark_all_as_read.ts b/src/server/api/endpoints/notifications/mark_all_as_read.ts deleted file mode 100644 index e5df648285..0000000000 --- a/src/server/api/endpoints/notifications/mark_all_as_read.ts +++ /dev/null @@ -1,41 +0,0 @@ -import Notification from '../../../../models/notification'; -import { publishMainStream } from '../../../../services/stream'; -import User from '../../../../models/user'; -import define from '../../define'; - -export const meta = { - desc: { - 'ja-JP': '全ての通知を既読にします。', - 'en-US': 'Mark all notifications as read.' - }, - - tags: ['notifications', 'account'], - - requireCredential: true, - - kind: 'notification-write' -}; - -export default define(meta, async (ps, user) => { - // Update documents - await Notification.update({ - notifieeId: user._id, - isRead: false - }, { - $set: { - isRead: true - } - }, { - multi: true - }); - - // Update flag - User.update({ _id: user._id }, { - $set: { - hasUnreadNotification: false - } - }); - - // 全ての通知を読みましたよというイベントを発行 - publishMainStream(user._id, 'readAllNotifications'); -}); -- cgit v1.2.3-freya