1
0
mirror of https://github.com/MisskeyIO/misskey synced 2024-12-28 13:38:41 +09:00
MisskeyIO/src/server/api/endpoints/i/read-all-messaging-messages.ts

45 lines
822 B
TypeScript
Raw Normal View History

2018-12-28 05:06:25 +09:00
import User from '../../../../models/user';
2019-02-05 14:14:23 +09:00
import { publishMainStream } from '../../../../services/stream';
2018-12-28 05:06:25 +09: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.'
},
tags: ['account', 'messaging'],
2018-12-28 05:06:25 +09:00
requireCredential: true,
kind: 'account-write',
params: {
}
};
export default define(meta, async (ps, user) => {
2018-12-28 05:06:25 +09: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');
return;
});