server: add diagnostics for failing visibility
All checks were successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-client Pipeline was successful
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/lint-backend Pipeline was successful
ci/woodpecker/push/lint-sw Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
All checks were successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-client Pipeline was successful
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/lint-backend Pipeline was successful
ci/woodpecker/push/lint-sw Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
This commit is contained in:
parent
c777c2ed04
commit
0a7352eda9
3 changed files with 16 additions and 1 deletions
|
@ -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 [];
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
|
|
|
@ -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.');
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue