fix: perform visibility query in second stage
Some checks failed
ci/woodpecker/pr/lint-foundkey-js Pipeline was successful
ci/woodpecker/pr/lint-backend Pipeline failed
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-client Pipeline was successful
ci/woodpecker/push/lint-backend Pipeline was successful
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/pr/lint-client Pipeline failed
ci/woodpecker/pr/test Pipeline failed
Some checks failed
ci/woodpecker/pr/lint-foundkey-js Pipeline was successful
ci/woodpecker/pr/lint-backend Pipeline failed
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-client Pipeline was successful
ci/woodpecker/push/lint-backend Pipeline was successful
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/pr/lint-client Pipeline failed
ci/woodpecker/pr/test Pipeline failed
This commit is contained in:
parent
f5ea7b6d5b
commit
8a90dfa60b
16 changed files with 42 additions and 55 deletions
|
@ -1,12 +1,17 @@
|
|||
import { Brackets, SelectQueryBuilder } from 'typeorm';
|
||||
import { SelectQueryBuilder } from 'typeorm';
|
||||
import { User } from '@/models/entities/user.js';
|
||||
import { Followings } from '@/models/index.js';
|
||||
import { Note } from '@/models/entities/note.js';
|
||||
import { Notes } from '@/models/index.js';
|
||||
|
||||
export function generateVisibilityQuery(q: SelectQueryBuilder<any>, me?: { id: User['id'] } | null) {
|
||||
if (me == null) {
|
||||
q.andWhere('note_visible(note.id, null)');
|
||||
export function visibilityQuery(q: SelectQueryBuilder<Note>, meId?: User['id'] | null = null): SelectQueryBuilder<Note> {
|
||||
const superQuery = Notes.createQueryBuilder()
|
||||
.from(() => q, 'note');
|
||||
|
||||
if (meId == null) {
|
||||
superQuery.where('note_visible(note.id, null);');
|
||||
} else {
|
||||
q.andWhere('note_visible(note.id, :meId)');
|
||||
q.setParameters({ meId: me.id });
|
||||
superQuery.where('note_visible(note.id, :meId)', { meId });
|
||||
}
|
||||
|
||||
return q;
|
||||
}
|
||||
|
|
|
@ -2,7 +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 { generateVisibilityQuery } from './generate-visibility-query.js';
|
||||
import { visibilityQuery } from './generate-visibility-query.js';
|
||||
|
||||
/**
|
||||
* Get note for API processing, taking into account visibility.
|
||||
|
@ -13,9 +13,7 @@ export async function getNote(noteId: Note['id'], me: { id: User['id'] } | null)
|
|||
id: noteId,
|
||||
});
|
||||
|
||||
generateVisibilityQuery(query, me);
|
||||
|
||||
const note = await query.getOne();
|
||||
const note = await visibilityQuery(query, me).getOne();
|
||||
|
||||
if (note == null) {
|
||||
throw new IdentifiableError('9725d0ce-ba28-4dde-95a7-2cbb2c15de24', 'No such note.');
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { readNote } from '@/services/note/read.js';
|
||||
import { Antennas, Notes, AntennaNotes } from '@/models/index.js';
|
||||
import { makePaginationQuery } from '../../common/make-pagination-query.js';
|
||||
import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
|
||||
import { visibilityQuery } from '../../common/generate-visibility-query.js';
|
||||
import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
|
||||
import { generateBlockedUserQuery } from '../../common/generate-block-query.js';
|
||||
import define from '../../define.js';
|
||||
|
@ -65,11 +65,10 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
.leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner')
|
||||
.andWhere('antennaNote.antennaId = :antennaId', { antennaId: antenna.id });
|
||||
|
||||
generateVisibilityQuery(query, user);
|
||||
generateMutedUserQuery(query, user);
|
||||
generateBlockedUserQuery(query, user);
|
||||
|
||||
const notes = await query
|
||||
const notes = await visibilityQuery(query, user)
|
||||
.take(ps.limit)
|
||||
.getMany();
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { ClipNotes, Clips, Notes } from '@/models/index.js';
|
||||
import define from '../../define.js';
|
||||
import { makePaginationQuery } from '../../common/make-pagination-query.js';
|
||||
import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
|
||||
import { visibilityQuery } from '../../common/generate-visibility-query.js';
|
||||
import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
|
||||
import { ApiError } from '../../error.js';
|
||||
import { generateBlockedUserQuery } from '../../common/generate-block-query.js';
|
||||
|
@ -65,12 +65,11 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
.andWhere('clipNote.clipId = :clipId', { clipId: clip.id });
|
||||
|
||||
if (user) {
|
||||
generateVisibilityQuery(query, user);
|
||||
generateMutedUserQuery(query, user);
|
||||
generateBlockedUserQuery(query, user);
|
||||
}
|
||||
|
||||
const notes = await query
|
||||
const notes = await visibilityQuery(query, user)
|
||||
.take(ps.limit)
|
||||
.getMany();
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Notes } from '@/models/index.js';
|
||||
import define from '../../define.js';
|
||||
import { makePaginationQuery } from '../../common/make-pagination-query.js';
|
||||
import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
|
||||
import { visibilityQuery } from '../../common/generate-visibility-query.js';
|
||||
import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
|
||||
import { generateBlockedUserQuery } from '../../common/generate-block-query.js';
|
||||
|
||||
|
@ -55,13 +55,12 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
.leftJoinAndSelect('user.avatar', 'avatar')
|
||||
.leftJoinAndSelect('user.banner', 'banner');
|
||||
|
||||
generateVisibilityQuery(query, user);
|
||||
if (user) {
|
||||
generateMutedUserQuery(query, user);
|
||||
generateBlockedUserQuery(query, user);
|
||||
}
|
||||
|
||||
const notes = await query.getMany();
|
||||
const notes = await visibilityQuery(query, user).getMany();
|
||||
|
||||
return await Notes.packMany(notes, user, { detail: false });
|
||||
});
|
||||
|
|
|
@ -5,7 +5,7 @@ import { activeUsersChart } from '@/services/chart/index.js';
|
|||
import define from '../../define.js';
|
||||
import { ApiError } from '../../error.js';
|
||||
import { makePaginationQuery } from '../../common/make-pagination-query.js';
|
||||
import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
|
||||
import { visibilityQuery } from '../../common/generate-visibility-query.js';
|
||||
import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
|
||||
import { generateRepliesQuery } from '../../common/generate-replies-query.js';
|
||||
import { generateMutedNoteQuery } from '../../common/generate-muted-note-query.js';
|
||||
|
@ -84,7 +84,6 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
|
||||
generateChannelQuery(query, user);
|
||||
generateRepliesQuery(query, user);
|
||||
generateVisibilityQuery(query, user);
|
||||
generateMutedUserQuery(query, user);
|
||||
generateMutedNoteQuery(query, user);
|
||||
generateBlockedUserQuery(query, user);
|
||||
|
@ -125,7 +124,7 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
}
|
||||
//#endregion
|
||||
|
||||
const timeline = await query.take(ps.limit).getMany();
|
||||
const timeline = await visibilityQuery(query, user).take(ps.limit).getMany();
|
||||
|
||||
process.nextTick(() => {
|
||||
activeUsersChart.read(user);
|
||||
|
|
|
@ -6,7 +6,7 @@ import define from '../../define.js';
|
|||
import { ApiError } from '../../error.js';
|
||||
import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
|
||||
import { makePaginationQuery } from '../../common/make-pagination-query.js';
|
||||
import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
|
||||
import { visibilityQuery } from '../../common/generate-visibility-query.js';
|
||||
import { generateRepliesQuery } from '../../common/generate-replies-query.js';
|
||||
import { generateMutedNoteQuery } from '../../common/generate-muted-note-query.js';
|
||||
import { generateChannelQuery } from '../../common/generate-channel-query.js';
|
||||
|
@ -77,7 +77,6 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
|
||||
generateChannelQuery(query, user);
|
||||
generateRepliesQuery(query, user);
|
||||
generateVisibilityQuery(query, user);
|
||||
if (user) generateMutedUserQuery(query, user);
|
||||
if (user) generateMutedNoteQuery(query, user);
|
||||
if (user) generateBlockedUserQuery(query, user);
|
||||
|
@ -103,7 +102,7 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
}
|
||||
//#endregion
|
||||
|
||||
const timeline = await query.take(ps.limit).getMany();
|
||||
const timeline = await visibilityQuery(query, user).take(ps.limit).getMany();
|
||||
|
||||
process.nextTick(() => {
|
||||
if (user) {
|
||||
|
|
|
@ -3,7 +3,7 @@ import { noteVisibilities } from 'foundkey-js';
|
|||
import { readNote } from '@/services/note/read.js';
|
||||
import { Notes, Followings } from '@/models/index.js';
|
||||
import define from '../../define.js';
|
||||
import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
|
||||
import { visibilityQuery } from '../../common/generate-visibility-query.js';
|
||||
import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
|
||||
import { makePaginationQuery } from '../../common/make-pagination-query.js';
|
||||
import { generateBlockedUserQuery } from '../../common/generate-block-query.js';
|
||||
|
@ -63,7 +63,6 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
.leftJoinAndSelect('renoteUser.avatar', 'renoteUserAvatar')
|
||||
.leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner');
|
||||
|
||||
generateVisibilityQuery(query, user);
|
||||
generateMutedUserQuery(query, user);
|
||||
generateMutedNoteThreadQuery(query, user);
|
||||
generateBlockedUserQuery(query, user);
|
||||
|
@ -77,7 +76,7 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
query.setParameters(followingQuery.getParameters());
|
||||
}
|
||||
|
||||
const mentions = await query.take(ps.limit).getMany();
|
||||
const mentions = await visibilityQuery(query, user).take(ps.limit).getMany();
|
||||
|
||||
readNote(user.id, mentions);
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import { Notes } from '@/models/index.js';
|
|||
import define from '../../define.js';
|
||||
import { getNote } from '../../common/getters.js';
|
||||
import { ApiError } from '../../error.js';
|
||||
import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
|
||||
import { visibilityQuery } from '../../common/generate-visibility-query.js';
|
||||
import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
|
||||
import { makePaginationQuery } from '../../common/make-pagination-query.js';
|
||||
import { generateBlockedUserQuery } from '../../common/generate-block-query.js';
|
||||
|
@ -57,11 +57,10 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
.leftJoinAndSelect('renoteUser.avatar', 'renoteUserAvatar')
|
||||
.leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner');
|
||||
|
||||
generateVisibilityQuery(query, user);
|
||||
if (user) generateMutedUserQuery(query, user);
|
||||
if (user) generateBlockedUserQuery(query, user);
|
||||
|
||||
const renotes = await query.take(ps.limit).getMany();
|
||||
const renotes = await visibilityQuery(query, user).take(ps.limit).getMany();
|
||||
|
||||
return await Notes.packMany(renotes, user);
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Notes } from '@/models/index.js';
|
||||
import define from '../../define.js';
|
||||
import { makePaginationQuery } from '../../common/make-pagination-query.js';
|
||||
import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
|
||||
import { visibilityQuery } from '../../common/generate-visibility-query.js';
|
||||
import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
|
||||
import { generateBlockedUserQuery } from '../../common/generate-block-query.js';
|
||||
|
||||
|
@ -48,11 +48,10 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
.leftJoinAndSelect('renoteUser.avatar', 'renoteUserAvatar')
|
||||
.leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner');
|
||||
|
||||
generateVisibilityQuery(query, user);
|
||||
if (user) generateMutedUserQuery(query, user);
|
||||
if (user) generateBlockedUserQuery(query, user);
|
||||
|
||||
const timeline = await query.take(ps.limit).getMany();
|
||||
const timeline = await visibilityQuery(query, user).take(ps.limit).getMany();
|
||||
|
||||
return await Notes.packMany(timeline, user);
|
||||
});
|
||||
|
|
|
@ -5,7 +5,7 @@ import { normalizeForSearch } from '@/misc/normalize-for-search.js';
|
|||
import define from '../../define.js';
|
||||
import { makePaginationQuery } from '../../common/make-pagination-query.js';
|
||||
import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
|
||||
import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
|
||||
import { visibilityQuery } from '../../common/generate-visibility-query.js';
|
||||
import { generateBlockedUserQuery } from '../../common/generate-block-query.js';
|
||||
|
||||
export const meta = {
|
||||
|
@ -80,7 +80,6 @@ export default define(meta, paramDef, async (ps, me) => {
|
|||
.leftJoinAndSelect('renoteUser.avatar', 'renoteUserAvatar')
|
||||
.leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner');
|
||||
|
||||
generateVisibilityQuery(query, me);
|
||||
if (me) generateMutedUserQuery(query, me);
|
||||
if (me) generateBlockedUserQuery(query, me);
|
||||
|
||||
|
@ -134,7 +133,7 @@ export default define(meta, paramDef, async (ps, me) => {
|
|||
}
|
||||
|
||||
// Search notes
|
||||
const notes = await query.take(ps.limit).getMany();
|
||||
const notes = await visibilityQuery(query, me).take(ps.limit).getMany();
|
||||
|
||||
return await Notes.packMany(notes, me);
|
||||
});
|
||||
|
|
|
@ -4,7 +4,7 @@ import config from '@/config/index.js';
|
|||
import es from '@/db/elasticsearch.js';
|
||||
import define from '../../define.js';
|
||||
import { makePaginationQuery } from '../../common/make-pagination-query.js';
|
||||
import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
|
||||
import { visibilityQuery } from '../../common/generate-visibility-query.js';
|
||||
import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
|
||||
import { generateBlockedUserQuery } from '../../common/generate-block-query.js';
|
||||
|
||||
|
@ -68,11 +68,10 @@ export default define(meta, paramDef, async (ps, me) => {
|
|||
.leftJoinAndSelect('renoteUser.avatar', 'renoteUserAvatar')
|
||||
.leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner');
|
||||
|
||||
generateVisibilityQuery(query, me);
|
||||
if (me) generateMutedUserQuery(query, me);
|
||||
if (me) generateBlockedUserQuery(query, me);
|
||||
|
||||
const notes = await query.take(ps.limit).getMany();
|
||||
const notes = await visibilityQuery(query, me).take(ps.limit).getMany();
|
||||
|
||||
return await Notes.packMany(notes, me);
|
||||
} else {
|
||||
|
|
|
@ -3,7 +3,7 @@ import { Notes, Followings } from '@/models/index.js';
|
|||
import { activeUsersChart } from '@/services/chart/index.js';
|
||||
import define from '../../define.js';
|
||||
import { makePaginationQuery } from '../../common/make-pagination-query.js';
|
||||
import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
|
||||
import { visibilityQuery } from '../../common/generate-visibility-query.js';
|
||||
import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
|
||||
import { generateRepliesQuery } from '../../common/generate-replies-query.js';
|
||||
import { generateMutedNoteQuery } from '../../common/generate-muted-note-query.js';
|
||||
|
@ -82,7 +82,6 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
|
||||
generateChannelQuery(query, user);
|
||||
generateRepliesQuery(query, user);
|
||||
generateVisibilityQuery(query, user);
|
||||
generateMutedUserQuery(query, user);
|
||||
generateMutedNoteQuery(query, user);
|
||||
generateBlockedUserQuery(query, user);
|
||||
|
@ -123,7 +122,7 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
}
|
||||
//#endregion
|
||||
|
||||
const timeline = await query.take(ps.limit).getMany();
|
||||
const timeline = await visibilityQuery(query, user).take(ps.limit).getMany();
|
||||
|
||||
process.nextTick(() => {
|
||||
activeUsersChart.read(user);
|
||||
|
|
|
@ -4,7 +4,7 @@ import { activeUsersChart } from '@/services/chart/index.js';
|
|||
import define from '../../define.js';
|
||||
import { ApiError } from '../../error.js';
|
||||
import { makePaginationQuery } from '../../common/make-pagination-query.js';
|
||||
import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
|
||||
import { visibilityQuery } from '../../common/generate-visibility-query.js';
|
||||
|
||||
export const meta = {
|
||||
tags: ['notes', 'lists'],
|
||||
|
@ -70,8 +70,6 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
.leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner')
|
||||
.andWhere('userListJoining.userListId = :userListId', { userListId: list.id });
|
||||
|
||||
generateVisibilityQuery(query, user);
|
||||
|
||||
if (ps.includeMyRenotes === false) {
|
||||
query.andWhere(new Brackets(qb => {
|
||||
qb.orWhere('note.userId != :meId', { meId: user.id });
|
||||
|
@ -107,7 +105,7 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
}
|
||||
//#endregion
|
||||
|
||||
const timeline = await query.take(ps.limit).getMany();
|
||||
const timeline = await visibilityQuery(query, user).take(ps.limit).getMany();
|
||||
|
||||
activeUsersChart.read(user);
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import define from '../../define.js';
|
|||
import { ApiError } from '../../error.js';
|
||||
import { getUser } from '../../common/getters.js';
|
||||
import { makePaginationQuery } from '../../common/make-pagination-query.js';
|
||||
import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
|
||||
import { visibilityQuery } from '../../common/generate-visibility-query.js';
|
||||
import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
|
||||
import { generateBlockedUserQuery } from '../../common/generate-block-query.js';
|
||||
|
||||
|
@ -69,7 +69,6 @@ export default define(meta, paramDef, async (ps, me) => {
|
|||
.leftJoinAndSelect('renoteUser.avatar', 'renoteUserAvatar')
|
||||
.leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner');
|
||||
|
||||
generateVisibilityQuery(query, me);
|
||||
if (me) {
|
||||
generateMutedUserQuery(query, me);
|
||||
generateBlockedUserQuery(query, me);
|
||||
|
@ -110,7 +109,7 @@ export default define(meta, paramDef, async (ps, me) => {
|
|||
|
||||
//#endregion
|
||||
|
||||
const timeline = await query.take(ps.limit).getMany();
|
||||
const timeline = await visibilityQuery(query, me).take(ps.limit).getMany();
|
||||
|
||||
return await Notes.packMany(timeline, me);
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { NoteReactions, UserProfiles } from '@/models/index.js';
|
||||
import define from '../../define.js';
|
||||
import { makePaginationQuery } from '../../common/make-pagination-query.js';
|
||||
import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
|
||||
import { visibilityQuery } from '../../common/generate-visibility-query.js';
|
||||
import { ApiError } from '../../error.js';
|
||||
|
||||
export const meta = {
|
||||
|
@ -50,9 +50,7 @@ export default define(meta, paramDef, async (ps, me) => {
|
|||
.andWhere('reaction.userId = :userId', { userId: ps.userId })
|
||||
.leftJoinAndSelect('reaction.note', 'note');
|
||||
|
||||
generateVisibilityQuery(query, me);
|
||||
|
||||
const reactions = await query
|
||||
const reactions = await visibilityQuery(query, me)
|
||||
.take(ps.limit)
|
||||
.getMany();
|
||||
|
||||
|
|
Loading…
Reference in a new issue