diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2017-12-22 14:35:47 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2017-12-22 14:35:47 +0900 |
| commit | ef5a963b32afd5842894a2a61fa4c2d078853224 (patch) | |
| tree | 9dafe55c59a779767a4d199420c274d652692f86 /src/api/endpoints | |
| parent | wip (diff) | |
| download | sharkey-ef5a963b32afd5842894a2a61fa4c2d078853224.tar.gz sharkey-ef5a963b32afd5842894a2a61fa4c2d078853224.tar.bz2 sharkey-ef5a963b32afd5842894a2a61fa4c2d078853224.zip | |
wip
Diffstat (limited to 'src/api/endpoints')
| -rw-r--r-- | src/api/endpoints/messaging/unread.ts | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/api/endpoints/messaging/unread.ts b/src/api/endpoints/messaging/unread.ts index 40bc83fe1c..c4326e1d22 100644 --- a/src/api/endpoints/messaging/unread.ts +++ b/src/api/endpoints/messaging/unread.ts @@ -2,6 +2,7 @@ * Module dependencies */ import Message from '../../models/messaging-message'; +import Mute from '../../models/mute'; /** * Get count of unread messages @@ -11,8 +12,17 @@ import Message from '../../models/messaging-message'; * @return {Promise<any>} */ module.exports = (params, user) => new Promise(async (res, rej) => { + const mute = await Mute.find({ + muter_id: user._id, + deleted_at: { $exists: false } + }); + const mutedUserIds = mute.map(m => m.mutee_id); + const count = await Message .count({ + user_id: { + $nin: mutedUserIds + }, recipient_id: user._id, is_read: false }); |