summaryrefslogtreecommitdiff
path: root/src/api/endpoints/messaging/unread.ts
blob: 40bc83fe1c00ae2ce5a758d35b33bf7af8ce7417 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/**
 * Module dependencies
 */
import Message from '../../models/messaging-message';

/**
 * Get count of unread messages
 *
 * @param {any} params
 * @param {any} user
 * @return {Promise<any>}
 */
module.exports = (params, user) => new Promise(async (res, rej) => {
	const count = await Message
		.count({
			recipient_id: user._id,
			is_read: false
		});

	res({
		count: count
	});
});