diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2017-12-22 07:38:57 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2017-12-22 07:38:57 +0900 |
| commit | 8b515b4dae8c272257ee8892713fe954f0ff9c4a (patch) | |
| tree | edadde7900fa4caa61b23b96242c7758665062f8 /src/api/endpoints | |
| parent | wip (diff) | |
| download | sharkey-8b515b4dae8c272257ee8892713fe954f0ff9c4a.tar.gz sharkey-8b515b4dae8c272257ee8892713fe954f0ff9c4a.tar.bz2 sharkey-8b515b4dae8c272257ee8892713fe954f0ff9c4a.zip | |
wip
Diffstat (limited to 'src/api/endpoints')
| -rw-r--r-- | src/api/endpoints/notifications/get_unread_count.ts | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/api/endpoints/notifications/get_unread_count.ts b/src/api/endpoints/notifications/get_unread_count.ts index 9514e78713..845d6b29ce 100644 --- a/src/api/endpoints/notifications/get_unread_count.ts +++ b/src/api/endpoints/notifications/get_unread_count.ts @@ -2,6 +2,7 @@ * Module dependencies */ import Notification from '../../models/notification'; +import Mute from '../../models/mute'; /** * Get count of unread notifications @@ -11,9 +12,18 @@ import Notification from '../../models/notification'; * @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 Notification .count({ notifiee_id: user._id, + notifier_id: { + $nin: mutedUserIds + }, is_read: false }); |