diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2017-12-22 17:42:03 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-12-22 17:42:03 +0900 |
| commit | e06dd199a7f3f0b1fd3bd67e06e463c2aa58633c (patch) | |
| tree | 5e9dc021c78288097cc02671f0c9a4ef04a83e2d /src/api/endpoints/posts/timeline.ts | |
| parent | Fix bug (diff) | |
| parent | Update create.ts (diff) | |
| download | sharkey-e06dd199a7f3f0b1fd3bd67e06e463c2aa58633c.tar.gz sharkey-e06dd199a7f3f0b1fd3bd67e06e463c2aa58633c.tar.bz2 sharkey-e06dd199a7f3f0b1fd3bd67e06e463c2aa58633c.zip | |
Merge pull request #1028 from syuilo/mute
Mute
Diffstat (limited to 'src/api/endpoints/posts/timeline.ts')
| -rw-r--r-- | src/api/endpoints/posts/timeline.ts | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/api/endpoints/posts/timeline.ts b/src/api/endpoints/posts/timeline.ts index 91cba0a047..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 @@ -77,7 +86,17 @@ module.exports = async (params, user, app) => { channel_id: { $in: watchingChannelIds } - }] + }], + // mute + user_id: { + $nin: mutedUserIds + }, + '_reply.user_id': { + $nin: mutedUserIds + }, + '_repost.user_id': { + $nin: mutedUserIds + }, } as any; if (sinceId) { |