wip
This commit is contained in:
parent
11e05a3a32
commit
a134aa5a81
5 changed files with 228 additions and 5 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue