おすすめのアンケートでミュートユーザーのものは表示しない (#4067)

This commit is contained in:
MeiMei 2019-01-31 23:14:45 +09:00 committed by syuilo
parent 6d3408ae73
commit c34a278533
1 changed files with 8 additions and 1 deletions

View File

@ -2,6 +2,7 @@ import $ from 'cafy';
import Vote from '../../../../../models/poll-vote'; import Vote from '../../../../../models/poll-vote';
import Note, { pack } from '../../../../../models/note'; import Note, { pack } from '../../../../../models/note';
import define from '../../../define'; import define from '../../../define';
import Mute from '../../../../../models/mute';
export const meta = { export const meta = {
desc: { desc: {
@ -37,6 +38,11 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => {
const nin = votes && votes.length != 0 ? votes.map(v => v.noteId) : []; const nin = votes && votes.length != 0 ? votes.map(v => v.noteId) : [];
// ミュートしているユーザーを取得
const mutedUserIds = await Mute.find({
muterId: user._id
}).then(ms => ms.map(m => m.muteeId));
const notes = await Note const notes = await Note
.find({ .find({
'_user.host': null, '_user.host': null,
@ -44,7 +50,8 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => {
$nin: nin $nin: nin
}, },
userId: { userId: {
$ne: user._id $ne: user._id,
$nin: mutedUserIds
}, },
poll: { poll: {
$exists: true, $exists: true,