From 854ac95511ef017b891185b17921291bb27c1ef2 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 10 Oct 2023 20:06:02 +0900 Subject: [PATCH] =?UTF-8?q?fix(backend):=20=E3=82=BB=E3=83=B3=E3=82=B7?= =?UTF-8?q?=E3=83=86=E3=82=A3=E3=83=96=E8=A8=AD=E5=AE=9A=E3=81=95=E3=82=8C?= =?UTF-8?q?=E3=81=9F=E3=83=81=E3=83=A3=E3=83=B3=E3=83=8D=E3=83=AB=E3=81=AE?= =?UTF-8?q?=E6=8A=95=E7=A8=BF=E3=82=92users/notes=E3=81=A7=E8=BF=94?= =?UTF-8?q?=E3=81=95=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/backend/src/server/api/endpoints/users/notes.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/users/notes.ts b/packages/backend/src/server/api/endpoints/users/notes.ts index d2a65142a5..dfef35986e 100644 --- a/packages/backend/src/server/api/endpoints/users/notes.ts +++ b/packages/backend/src/server/api/endpoints/users/notes.ts @@ -77,6 +77,7 @@ export default class extends Endpoint { // eslint- const untilId = ps.untilId ?? (ps.untilDate ? this.idService.genId(new Date(ps.untilDate!)) : null); const sinceId = ps.sinceId ?? (ps.sinceDate ? this.idService.genId(new Date(ps.sinceDate!)) : null); const isRangeSpecified = untilId != null && sinceId != null; + const isSelf = me && (me.id === ps.userId); if (isRangeSpecified || sinceId == null) { const [ @@ -100,7 +101,7 @@ export default class extends Endpoint { // eslint- noteIds = noteIds.slice(0, ps.limit); if (noteIds.length > 0) { - const isFollowing = me ? me.id === ps.userId || Object.hasOwn(await this.cacheService.userFollowingsCache.fetch(me.id), ps.userId) : false; + const isFollowing = me && Object.hasOwn(await this.cacheService.userFollowingsCache.fetch(me.id), ps.userId); const query = this.notesRepository.createQueryBuilder('note') .where('note.id IN (:...noteIds)', { noteIds: noteIds }) @@ -122,8 +123,9 @@ export default class extends Endpoint { // eslint- } } + if (note.channel?.isSensitive && !isSelf) return false; if (note.visibility === 'specified' && (!me || (me.id !== note.userId && !note.visibleUserIds.some(v => v === me.id)))) return false; - if (note.visibility === 'followers' && !isFollowing) return false; + if (note.visibility === 'followers' && !isFollowing && !isSelf) return false; return true; });