From 111863b396a01c53860c37f6a419937ce1bbfa63 Mon Sep 17 00:00:00 2001 From: dakkar Date: Tue, 31 Oct 2023 15:18:37 +0000 Subject: [PATCH 1/2] try to fix #118 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit when fetching notes from Redis, we need to re-check the criteria from the API request, because `userTimelineWithFiles`, `userTimelineWithReplies`, `userTimelineWithChannel` all get merged together, so `noteIds` may well contain notes without attachments… --- packages/backend/src/server/api/endpoints/users/notes.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/backend/src/server/api/endpoints/users/notes.ts b/packages/backend/src/server/api/endpoints/users/notes.ts index 343d320f6e..9e87d9a235 100644 --- a/packages/backend/src/server/api/endpoints/users/notes.ts +++ b/packages/backend/src/server/api/endpoints/users/notes.ts @@ -123,6 +123,8 @@ export default class extends Endpoint { // eslint- } } + if (ps.withFiles && !note.fileIds) return false; + 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 && !isSelf) return false; From 044d3d76e7c84726518bb17e344cf6df1080c1c0 Mon Sep 17 00:00:00 2001 From: dakkar Date: Tue, 31 Oct 2023 16:16:39 +0000 Subject: [PATCH 2/2] actually fix #118 `note.fileIds` is an array, it's always going to be truthy; we need to check the length, like a similar `if` does just a few lines above --- packages/backend/src/server/api/endpoints/users/notes.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend/src/server/api/endpoints/users/notes.ts b/packages/backend/src/server/api/endpoints/users/notes.ts index 9e87d9a235..31ad3e68d6 100644 --- a/packages/backend/src/server/api/endpoints/users/notes.ts +++ b/packages/backend/src/server/api/endpoints/users/notes.ts @@ -123,7 +123,7 @@ export default class extends Endpoint { // eslint- } } - if (ps.withFiles && !note.fileIds) return false; + if (ps.withFiles && note.fileIds.length === 0) return false; 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;