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