From 810c5b580b1ca84b28dc8a89cee74a3ee75a6e1e Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 21 Jan 2019 21:51:58 +0900 Subject: [PATCH] [Server] Fix #3947 --- src/server/api/endpoints/users/notes.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/server/api/endpoints/users/notes.ts b/src/server/api/endpoints/users/notes.ts index 7d73fde1c..fdb862de0 100644 --- a/src/server/api/endpoints/users/notes.ts +++ b/src/server/api/endpoints/users/notes.ts @@ -4,6 +4,7 @@ import Note, { packMany } from '../../../../models/note'; import User from '../../../../models/user'; import define from '../../define'; import { countIf } from '../../../../prelude/array'; +import Following from '../../../../models/following'; export const meta = { desc: { @@ -160,13 +161,20 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => { return rej('user not found'); } + const isFollowing = me == null ? false : ((await Following.findOne({ + followerId: me._id, + followeeId: user._id + })) != null); + //#region Construct query const sort = { } as any; const visibleQuery = me == null ? [{ - visibility: { $in: [ 'public', 'home' ] } + visibility: { $in: ['public', 'home'] } }] : [{ - visibility: { $in: [ 'public', 'home' ] } + visibility: { + $in: isFollowing ? ['public', 'home', 'followers'] : ['public', 'home'] + } }, { // myself (for specified/private) userId: me._id