From ca9698651c76453ba6d0d1ec272de73d7a198f23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Acid=20Chicken=20=28=E7=A1=AB=E9=85=B8=E9=B6=8F=29?= Date: Sun, 2 Feb 2020 05:42:58 +0900 Subject: [PATCH] Fix hashtags contained in private notes are shown in trends (#5805) * Update trend.ts * Fix query * Update create.ts * Update create.ts * Update trend.ts --- src/server/api/endpoints/hashtags/trend.ts | 5 +++++ src/services/note/create.ts | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/server/api/endpoints/hashtags/trend.ts b/src/server/api/endpoints/hashtags/trend.ts index a004732f8..f820f0bed 100644 --- a/src/server/api/endpoints/hashtags/trend.ts +++ b/src/server/api/endpoints/hashtags/trend.ts @@ -1,3 +1,4 @@ +import { Brackets } from 'typeorm'; import define from '../../define'; import { fetchMeta } from '../../../../misc/fetch-meta'; import { Notes } from '../../../../models'; @@ -59,6 +60,10 @@ export default define(meta, async () => { const tagNotes = await Notes.createQueryBuilder('note') .where(`note.createdAt > :date`, { date: new Date(now.getTime() - rangeA) }) + .andWhere(new Brackets(qb => { qb + .where(`note.visibility = 'public'`) + .orWhere(`note.visibility = 'home'`); + })) .andWhere(`note.tags != '{}'`) .select(['note.tags', 'note.userId']) .cache(60000) // 1 min diff --git a/src/services/note/create.ts b/src/services/note/create.ts index e6433ac04..8bcf0d7d0 100644 --- a/src/services/note/create.ts +++ b/src/services/note/create.ts @@ -203,7 +203,9 @@ export default async (user: User, data: Option, silent = false) => new Promise