2018-11-02 04:47:44 +00:00
|
|
|
import User from '../../../../models/user';
|
2019-02-05 05:14:23 +00:00
|
|
|
import { publishMainStream } from '../../../../services/stream';
|
2018-10-18 21:36:59 +00:00
|
|
|
import NoteUnread from '../../../../models/note-unread';
|
2018-11-02 04:47:44 +00:00
|
|
|
import define from '../../define';
|
2018-10-18 21:36:59 +00:00
|
|
|
|
|
|
|
export const meta = {
|
|
|
|
desc: {
|
2018-10-20 06:46:01 +00:00
|
|
|
'ja-JP': '未読の投稿をすべて既読にします。',
|
|
|
|
'en-US': 'Mark all messages as read.'
|
2018-10-18 21:36:59 +00:00
|
|
|
},
|
|
|
|
|
2019-02-23 02:20:58 +00:00
|
|
|
tags: ['account'],
|
|
|
|
|
2018-10-18 21:36:59 +00:00
|
|
|
requireCredential: true,
|
|
|
|
|
|
|
|
kind: 'account-write',
|
|
|
|
|
|
|
|
params: {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-02-22 02:46:58 +00:00
|
|
|
export default define(meta, async (ps, user) => {
|
2018-10-18 21:36:59 +00:00
|
|
|
// Remove documents
|
|
|
|
await NoteUnread.remove({
|
|
|
|
userId: user._id
|
|
|
|
});
|
|
|
|
|
|
|
|
User.update({ _id: user._id }, {
|
|
|
|
$set: {
|
|
|
|
hasUnreadMentions: false,
|
|
|
|
hasUnreadSpecifiedNotes: false
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// 全て既読になったイベントを発行
|
|
|
|
publishMainStream(user._id, 'readAllUnreadMentions');
|
|
|
|
publishMainStream(user._id, 'readAllUnreadSpecifiedNotes');
|
|
|
|
|
2019-02-22 02:46:58 +00:00
|
|
|
return;
|
|
|
|
});
|