summaryrefslogtreecommitdiff
path: root/src/api/endpoints
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-12-22 07:38:57 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-12-22 07:38:57 +0900
commit8b515b4dae8c272257ee8892713fe954f0ff9c4a (patch)
treeedadde7900fa4caa61b23b96242c7758665062f8 /src/api/endpoints
parentwip (diff)
downloadsharkey-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.ts10
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
});