diff --git a/packages/backend/src/models/repositories/note.ts b/packages/backend/src/models/repositories/note.ts index 1ff4194ec..d93a47fc6 100644 --- a/packages/backend/src/models/repositories/note.ts +++ b/packages/backend/src/models/repositories/note.ts @@ -11,6 +11,7 @@ import { NoteReaction } from '@/models/entities/note-reaction.js'; import { User } from '@/models/entities/user.js'; import { awaitAll } from '@/prelude/await-all.js'; import { Users, PollVotes, DriveFiles, NoteReactions, Followings, Polls, Channels } from '../index.js'; +import { apiLogger } from '@/server/api/logger.js'; async function populatePoll(note: Note, meId: User['id'] | null) { const poll = await Polls.findOneByOrFail({ noteId: note.id }); @@ -270,6 +271,13 @@ export const NoteRepository = db.getRepository(Note).extend({ }))); // filter out rejected promises, only keep fulfilled values - return promises.flatMap(result => result.status === 'fulfilled' ? [result.value] : []); + return promises.flatMap((result, i) => { + if (result.status === 'fulfilled') { + return [result.value]; + } else { + apiLogger.error(`dropping note due to violating visibility restrictions, note ${notes[i].id} user ${meId}`); + return []; + } + }); }, }); diff --git a/packages/backend/src/server/api/common/getters.ts b/packages/backend/src/server/api/common/getters.ts index ca0fbf1ef..ea1c26964 100644 --- a/packages/backend/src/server/api/common/getters.ts +++ b/packages/backend/src/server/api/common/getters.ts @@ -2,6 +2,7 @@ import { IdentifiableError } from '@/misc/identifiable-error.js'; import { User } from '@/models/entities/user.js'; import { Note } from '@/models/entities/note.js'; import { Notes, Users } from '@/models/index.js'; +import { apiLogger } from '@/server/api/logger.js'; import { visibilityQuery } from './generate-visibility-query.js'; /** @@ -16,6 +17,7 @@ export async function getNote(noteId: Note['id'], me: { id: User['id'] } | null) const note = await visibilityQuery(query, me).getOne(); if (note == null) { + apiLogger.error(`user ${me.id} tried to view note ${noteId} violating visibility restrictions`); throw new IdentifiableError('9725d0ce-ba28-4dde-95a7-2cbb2c15de24', 'No such note.'); } diff --git a/packages/backend/src/server/api/endpoints/notes/timeline.ts b/packages/backend/src/server/api/endpoints/notes/timeline.ts index 2c7006248..89daa7c26 100644 --- a/packages/backend/src/server/api/endpoints/notes/timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/timeline.ts @@ -10,6 +10,7 @@ import { generateMutedNoteQuery } from '@/server/api/common/generate-muted-note- import { generateChannelQuery } from '@/server/api/common/generate-channel-query.js'; import { generateBlockedUserQuery } from '@/server/api/common/generate-block-query.js'; import { generateMutedRenotesQuery } from '@/server/api/common/generated-muted-renote-query.js'; +import { apiLogger } from '@/server/api/logger.js'; export const meta = { tags: ['notes'], @@ -124,6 +125,10 @@ export default define(meta, paramDef, async (ps, user) => { const timeline = await visibilityQuery(query, user).take(ps.limit).getMany(); + if (timeline.length < ps.limit) { + apiLogger.warn(`notes missing from TL for user ${user.id}?`); + } + process.nextTick(() => { activeUsersChart.read(user); });