blob: e5df648285006cd9ec04d0a47aa9e376caedbfb6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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');
});
|