misskey/src/api/endpoints/messaging/unread.js

28 lines
416 B
JavaScript
Raw Normal View History

2016-12-29 07:49:51 +09:00
'use strict';
/**
* Module dependencies
*/
import Message from '../../models/messaging-message';
/**
* Get count of unread messages
*
* @param {Object} params
* @param {Object} user
* @return {Promise<object>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>
{
const count = await Message
.count({
recipient_id: user._id,
is_read: false
});
res({
count: count
});
});