summaryrefslogtreecommitdiff
path: root/src/api/endpoints
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-12-22 07:26:23 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-12-22 07:26:23 +0900
commit6575a6de5bbcab9a88448e4366feb77f1845a580 (patch)
tree72a18a518f6e9f03ddf89098098c432ca0570100 /src/api/endpoints
parentwip (diff)
downloadsharkey-6575a6de5bbcab9a88448e4366feb77f1845a580.tar.gz
sharkey-6575a6de5bbcab9a88448e4366feb77f1845a580.tar.bz2
sharkey-6575a6de5bbcab9a88448e4366feb77f1845a580.zip
wip
Diffstat (limited to 'src/api/endpoints')
-rw-r--r--src/api/endpoints/i/notifications.ts23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/api/endpoints/i/notifications.ts b/src/api/endpoints/i/notifications.ts
index 48254e5e67..fb9be7f61b 100644
--- a/src/api/endpoints/i/notifications.ts
+++ b/src/api/endpoints/i/notifications.ts
@@ -3,6 +3,7 @@
*/
import $ from 'cafy';
import Notification from '../../models/notification';
+import Mute from '../../models/mute';
import serialize from '../../serializers/notification';
import getFriends from '../../common/get-friends';
import read from '../../common/read-notification';
@@ -45,8 +46,18 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
return rej('cannot set since_id and until_id');
}
+ const mute = await Mute.find({
+ muter_id: user._id,
+ deleted_at: { $exists: false }
+ });
+
const query = {
- notifiee_id: user._id
+ notifiee_id: user._id,
+ $and: [{
+ notifier_id: {
+ $nin: mute.map(m => m.mutee_id)
+ }
+ }]
} as any;
const sort = {
@@ -54,12 +65,14 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
};
if (following) {
- // ID list of the user $self and other users who the user follows
+ // ID list of the user itself and other users who the user follows
const followingIds = await getFriends(user._id);
- query.notifier_id = {
- $in: followingIds
- };
+ query.$and.push({
+ notifier_id: {
+ $in: followingIds
+ }
+ });
}
if (type) {