From d5e80caac8180b2bcb59e3dba9b280e8b2ab1903 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 22 Jan 2019 21:21:47 +0900 Subject: [PATCH] [Server] Fix #3958 --- src/server/api/endpoints/notes/replies.ts | 25 +++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/server/api/endpoints/notes/replies.ts b/src/server/api/endpoints/notes/replies.ts index 6c2b690ab..8386d6068 100644 --- a/src/server/api/endpoints/notes/replies.ts +++ b/src/server/api/endpoints/notes/replies.ts @@ -1,6 +1,7 @@ import $ from 'cafy'; import ID, { transform } from '../../../../misc/cafy-id'; import Note, { packMany } from '../../../../models/note'; import define from '../../define'; +import Mute from '../../../../models/mute'; export const meta = { desc: { @@ -33,13 +34,25 @@ export const meta = { }; export default define(meta, (ps, user) => new Promise(async (res, rej) => { + // ミュートしているユーザーを取得 + const mutedUserIds = user ? (await Mute.find({ + muterId: user._id + })).map(m => m.muteeId) : null; - const notes = await Note.find({ - replyId: ps.noteId - }, { - limit: ps.limit, - skip: ps.offset - }); + const q = { + replyId: ps.noteId + } as any; + + if (mutedUserIds && mutedUserIds.length > 0) { + q['userId'] = { + $nin: mutedUserIds + }; + } + + const notes = await Note.find(q, { + limit: ps.limit, + skip: ps.offset + }); res(await packMany(notes, user)); }));