mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-15 02:23:08 +02:00
43 lines
805 B
TypeScript
43 lines
805 B
TypeScript
|
import User from '../../../../models/user';
|
||
|
import { publishMainStream } from '../../../../stream';
|
||
|
import Message from '../../../../models/messaging-message';
|
||
|
import define from '../../define';
|
||
|
|
||
|
export const meta = {
|
||
|
desc: {
|
||
|
'ja-JP': 'トークメッセージをすべて既読にします。',
|
||
|
'en-US': 'Mark all talk messages as read.'
|
||
|
},
|
||
|
|
||
|
requireCredential: true,
|
||
|
|
||
|
kind: 'account-write',
|
||
|
|
||
|
params: {
|
||
|
}
|
||
|
};
|
||
|
|
||
|
export default define(meta, (ps, user) => new Promise(async (res, rej) => {
|
||
|
// 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');
|
||
|
|
||
|
res();
|
||
|
}));
|