2018-12-27 14:06:25 -06:00
|
|
|
import User from '../../../../models/user';
|
2019-02-04 23:14:23 -06:00
|
|
|
import { publishMainStream } from '../../../../services/stream';
|
2018-12-27 14:06:25 -06:00
|
|
|
import Message from '../../../../models/messaging-message';
|
|
|
|
import define from '../../define';
|
|
|
|
|
|
|
|
export const meta = {
|
|
|
|
desc: {
|
|
|
|
'ja-JP': 'トークメッセージをすべて既読にします。',
|
|
|
|
'en-US': 'Mark all talk messages as read.'
|
|
|
|
},
|
|
|
|
|
2019-02-22 20:20:58 -06:00
|
|
|
tags: ['account', 'messaging'],
|
|
|
|
|
2018-12-27 14:06:25 -06:00
|
|
|
requireCredential: true,
|
|
|
|
|
|
|
|
kind: 'account-write',
|
|
|
|
|
|
|
|
params: {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-02-21 20:46:58 -06:00
|
|
|
export default define(meta, async (ps, user) => {
|
2018-12-27 14:06:25 -06:00
|
|
|
// Update documents
|
|
|
|
await Message.update({
|
|
|
|
recipientId: user._id,
|
|
|
|
isRead: false
|
|
|
|
}, {
|
|
|
|
$set: {
|
|
|
|
isRead: true
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
multi: true
|
|
|
|
});
|
|
|
|
|
|
|
|
User.update({ _id: user._id }, {
|
|
|
|
$set: {
|
|
|
|
hasUnreadMessagingMessage: false
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
publishMainStream(user._id, 'readAllMessagingMessages');
|
|
|
|
|
2019-02-21 20:46:58 -06:00
|
|
|
return;
|
|
|
|
});
|