summaryrefslogtreecommitdiff
path: root/src/api/endpoints/posts
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-12-22 06:03:54 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-12-22 06:03:54 +0900
commita134aa5a81ea2c443153b3723abf662a8069e36a (patch)
treed16a0ecaace8cc9f8e134a5ea046f57015b27284 /src/api/endpoints/posts
parentwip (diff)
downloadsharkey-a134aa5a81ea2c443153b3723abf662a8069e36a.tar.gz
sharkey-a134aa5a81ea2c443153b3723abf662a8069e36a.tar.bz2
sharkey-a134aa5a81ea2c443153b3723abf662a8069e36a.zip
wip
Diffstat (limited to 'src/api/endpoints/posts')
-rw-r--r--src/api/endpoints/posts/timeline.ts19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/api/endpoints/posts/timeline.ts b/src/api/endpoints/posts/timeline.ts
index 6cc7825e64..da7ffd0c14 100644
--- a/src/api/endpoints/posts/timeline.ts
+++ b/src/api/endpoints/posts/timeline.ts
@@ -4,6 +4,7 @@
import $ from 'cafy';
import rap from '@prezzemolo/rap';
import Post from '../../models/post';
+import Mute from '../../models/mute';
import ChannelWatching from '../../models/channel-watching';
import getFriends from '../../common/get-friends';
import serialize from '../../serializers/post';
@@ -42,15 +43,23 @@ module.exports = async (params, user, app) => {
throw 'only one of since_id, until_id, since_date, until_date can be specified';
}
- const { followingIds, watchingChannelIds } = await rap({
+ const { followingIds, watchingChannelIds, mutedUserIds } = await rap({
// ID list of the user itself and other users who the user follows
followingIds: getFriends(user._id),
+
// Watchしているチャンネルを取得
watchingChannelIds: ChannelWatching.find({
user_id: user._id,
// 削除されたドキュメントは除く
deleted_at: { $exists: false }
- }).then(watches => watches.map(w => w.channel_id))
+ }).then(watches => watches.map(w => w.channel_id)),
+
+ // ミュートしているユーザーを取得
+ mutedUserIds: Mute.find({
+ muter_id: user._id,
+ // 削除されたドキュメントは除く
+ deleted_at: { $exists: false }
+ }).then(ms => ms.map(m => m.mutee_id))
});
//#region Construct query
@@ -80,13 +89,13 @@ module.exports = async (params, user, app) => {
}],
// mute
user_id: {
- $nin: mutes
+ $nin: mutedUserIds
},
'_reply.user_id': {
- $nin: mutes
+ $nin: mutedUserIds
},
'_repost.user_id': {
- $nin: mutes
+ $nin: mutedUserIds
},
} as any;