From 1151991b70a1675da47cf6bc3d7668e4d7889a4a Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Thu, 4 Aug 2022 14:13:12 -0700 Subject: [PATCH] t --- .../api/endpoints/notes/recommended-timeline.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/notes/recommended-timeline.ts b/packages/backend/src/server/api/endpoints/notes/recommended-timeline.ts index e89f8db3f1..da6fa81588 100644 --- a/packages/backend/src/server/api/endpoints/notes/recommended-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/recommended-timeline.ts @@ -1,6 +1,6 @@ import { Brackets } from 'typeorm'; import { fetchMeta } from '@/misc/fetch-meta.js'; -import { Notes, Users } from '@/models/index.js'; +import { Notes, Metas } from '@/models/index.js'; import { activeUsersChart } from '@/services/chart/index.js'; import define from '../../define.js'; import { ApiError } from '../../error.js'; @@ -65,13 +65,17 @@ export default define(meta, paramDef, async (ps, user) => { } } - // .andWhere('(note.userHost IN (:instances)) OR (note.userHost IS NULL)', { instances: instances }) + //#region Construct query + const recommendedQuery = Metas.createQueryBuilder('meta') + .select('meta.recommendedInstances') + .where('meta.recommendedInstances = ANY'); + //#region Construct query const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate) .andWhere(new Brackets(qb => { - qb.where('note.userHost IN (:instances)', { instances: m.recommendedInstances }) - .orWhere('note.userHost IS NULL'); + qb.where(`((note.userHost IN (${ recommendedQuery.getQuery() }))`) + .orWhere('(note.visibility = \'public\') AND (note.userHost IS NULL)'); })) .andWhere('(note.visibility = \'public\')') .innerJoinAndSelect('note.user', 'user')