From 7246e6ff5b5b0eb4f889ceb0885c00425ec14461 Mon Sep 17 00:00:00 2001 From: syuilo <4439005+syuilo@users.noreply.github.com> Date: Mon, 19 Aug 2024 14:03:39 +0900 Subject: [PATCH] wip --- .../src/server/api/endpoints/notes/featured.ts | 9 ++++++++- packages/frontend/src/pages/explore.featured.vue | 13 +++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/server/api/endpoints/notes/featured.ts b/packages/backend/src/server/api/endpoints/notes/featured.ts index dcd971360d..db0ec25f03 100644 --- a/packages/backend/src/server/api/endpoints/notes/featured.ts +++ b/packages/backend/src/server/api/endpoints/notes/featured.ts @@ -36,6 +36,7 @@ export const paramDef = { limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 }, untilId: { type: 'string', format: 'misskey:id' }, channelId: { type: 'string', nullable: true, format: 'misskey:id' }, + withSensitive: { type: 'boolean', default: true }, }, required: [], } as const; @@ -103,7 +104,13 @@ export default class extends Endpoint { // eslint- notes.sort((a, b) => a.id > b.id ? -1 : 1); - return await this.noteEntityService.packMany(notes, me); + let packed = await this.noteEntityService.packMany(notes, me); + + if (!ps.withSensitive) { + packed = packed.filter(note => note.files?.length === 0 || note.files?.every(file => !file.isSensitive)); + } + + return packed; }); } } diff --git a/packages/frontend/src/pages/explore.featured.vue b/packages/frontend/src/pages/explore.featured.vue index cfdb235d3a..d7f6ba138e 100644 --- a/packages/frontend/src/pages/explore.featured.vue +++ b/packages/frontend/src/pages/explore.featured.vue @@ -7,9 +7,11 @@ SPDX-License-Identifier: AGPL-3.0-only + + @@ -23,6 +25,17 @@ import { i18n } from '@/i18n.js'; const paginationForNotes = { endpoint: 'notes/featured' as const, limit: 10, + params: { + withSensitive: false, + }, +}; + +const paginationForNotesWithSensitive = { + endpoint: 'notes/featured' as const, + limit: 10, + params: { + withSensitive: true, + }, }; const paginationForPolls = {