paricafe/src/api/endpoints/messaging/unread.ts

24 lines
391 B
TypeScript
Raw Normal View History

2016-12-28 16:49:51 -06:00
/**
* Module dependencies
*/
import Message from '../../models/messaging-message';
/**
* Get count of unread messages
*
2017-03-01 02:37:01 -06:00
* @param {any} params
* @param {any} user
* @return {Promise<any>}
2016-12-28 16:49:51 -06:00
*/
2017-03-03 13:28:38 -06:00
module.exports = (params, user) => new Promise(async (res, rej) => {
2016-12-28 16:49:51 -06:00
const count = await Message
.count({
recipient_id: user._id,
is_read: false
});
res({
count: count
});
});