From f3c99323c661b742dec25acf0502c7b4b895fc3f Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 23 Mar 2020 19:47:02 +0900 Subject: [PATCH] Fix #6180 --- src/server/api/endpoints/notes/timeline.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/server/api/endpoints/notes/timeline.ts b/src/server/api/endpoints/notes/timeline.ts index 3eed9f0ca..d60136a9c 100644 --- a/src/server/api/endpoints/notes/timeline.ts +++ b/src/server/api/endpoints/notes/timeline.ts @@ -102,6 +102,13 @@ export const meta = { }; export default define(meta, async (ps, user) => { + const hasFollowing = (await Followings.count({ + where: { + followerId: user.id, + }, + take: 1 + })) !== 0; + //#region Construct query const followingQuery = Followings.createQueryBuilder('following') .select('following.followeeId') @@ -110,8 +117,8 @@ export default define(meta, async (ps, user) => { const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate) .andWhere(new Brackets(qb => { qb - .where(`note.userId IN (${ followingQuery.getQuery() })`) - .orWhere('note.userId = :meId', { meId: user.id }); + .where('note.userId = :meId', { meId: user.id }); + if (hasFollowing) qb.orWhere(`note.userId IN (${ followingQuery.getQuery() })`); })) .leftJoinAndSelect('note.user', 'user') .setParameters(followingQuery.getParameters());