From 13f69e4291d36ed85972ee43f0f61e8f43913f80 Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Tue, 27 Aug 2019 17:33:07 +0900 Subject: [PATCH] =?UTF-8?q?excludeNsfw=E3=82=84CW=E3=81=AENSFW=E6=89=B1?= =?UTF-8?q?=E3=81=84=E3=81=AA=E3=81=A9=20(#5341)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * NoteにisSensitive * Revert "NoteにisSensitive" This reverts commit 3d5bcfbaf078ff91257a508f817dd1ef4ea31d7b. * query excludeNsfw * AP deliverでCW付きはsensitiveにするように * excludeNsfwでCW付きも除くように --- src/remote/activitypub/renderer/note.ts | 2 +- src/server/api/endpoints/notes/local-timeline.ts | 8 ++------ src/server/api/endpoints/users/notes.ts | 6 ++---- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/remote/activitypub/renderer/note.ts b/src/remote/activitypub/renderer/note.ts index cbdff7d20..ca823941c 100644 --- a/src/remote/activitypub/renderer/note.ts +++ b/src/remote/activitypub/renderer/note.ts @@ -158,7 +158,7 @@ export default async function renderNote(note: Note, dive = true): Promise cc, inReplyTo, attachment: files.map(renderDocument), - sensitive: files.some(file => file.isSensitive), + sensitive: note.cw != null || files.some(file => file.isSensitive), tag, ...asPoll }; diff --git a/src/server/api/endpoints/notes/local-timeline.ts b/src/server/api/endpoints/notes/local-timeline.ts index c688b9325..4149c6f90 100644 --- a/src/server/api/endpoints/notes/local-timeline.ts +++ b/src/server/api/endpoints/notes/local-timeline.ts @@ -112,12 +112,8 @@ export default define(meta, async (ps, user) => { })); if (ps.excludeNsfw) { - // v11 TODO - /* - query['_files.isSensitive'] = { - $ne: true - }; - */ + query.andWhere('note.cw IS NULL'); + query.andWhere('0 = (SELECT COUNT(*) FROM drive_file df WHERE df.id = ANY(note."fileIds") AND df."isSensitive" = TRUE)'); } } //#endregion diff --git a/src/server/api/endpoints/users/notes.ts b/src/server/api/endpoints/users/notes.ts index c8be19ff1..4869bd09f 100644 --- a/src/server/api/endpoints/users/notes.ts +++ b/src/server/api/endpoints/users/notes.ts @@ -150,10 +150,8 @@ export default define(meta, async (ps, me) => { })); if (ps.excludeNsfw) { - // v11 TODO - /*query['_files.isSensitive'] = { - $ne: true - };*/ + query.andWhere('note.cw IS NULL'); + query.andWhere('0 = (SELECT COUNT(*) FROM drive_file df WHERE df.id = ANY(note."fileIds") AND df."isSensitive" = TRUE)'); } }