summaryrefslogtreecommitdiff
path: root/src/api/endpoints/i/notifications.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2017-12-22 17:42:03 +0900
committerGitHub <noreply@github.com>2017-12-22 17:42:03 +0900
commite06dd199a7f3f0b1fd3bd67e06e463c2aa58633c (patch)
tree5e9dc021c78288097cc02671f0c9a4ef04a83e2d /src/api/endpoints/i/notifications.ts
parentFix bug (diff)
parentUpdate create.ts (diff)
downloadmisskey-e06dd199a7f3f0b1fd3bd67e06e463c2aa58633c.tar.gz
misskey-e06dd199a7f3f0b1fd3bd67e06e463c2aa58633c.tar.bz2
misskey-e06dd199a7f3f0b1fd3bd67e06e463c2aa58633c.zip
Merge pull request #1028 from syuilo/mute
Mute
Diffstat (limited to 'src/api/endpoints/i/notifications.ts')
-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) {