fix: perform visibility query in second stage
Some checks failed
ci/woodpecker/pr/lint-backend Pipeline failed
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-backend Pipeline was successful
ci/woodpecker/push/lint-client Pipeline was successful
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/lint-sw Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/lint-sw Pipeline failed
ci/woodpecker/pr/test Pipeline failed
ci/woodpecker/pr/lint-foundkey-js Pipeline failed
ci/woodpecker/pr/lint-client Pipeline failed

This commit is contained in:
Johann150 2022-10-28 23:39:39 +02:00
parent 6b727e9383
commit d7d10ccd60
Signed by: Johann150
GPG key ID: 9EE6577A2A06F8F1
16 changed files with 42 additions and 55 deletions

View file

@ -1,12 +1,17 @@
import { Brackets, SelectQueryBuilder } from 'typeorm'; import { SelectQueryBuilder } from 'typeorm';
import { User } from '@/models/entities/user.js'; 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) { export function visibilityQuery(q: SelectQueryBuilder<Note>, meId?: User['id'] | null = null): SelectQueryBuilder<Note> {
if (me == null) { const superQuery = Notes.createQueryBuilder()
q.andWhere('note_visible(note.id, null)'); .from(() => q, 'note');
if (meId == null) {
superQuery.where('note_visible(note.id, null);');
} else { } else {
q.andWhere('note_visible(note.id, :meId)'); superQuery.where('note_visible(note.id, :meId)', { meId });
q.setParameters({ meId: me.id });
} }
return q;
} }

View file

@ -2,7 +2,7 @@ import { IdentifiableError } from '@/misc/identifiable-error.js';
import { User } from '@/models/entities/user.js'; import { User } from '@/models/entities/user.js';
import { Note } from '@/models/entities/note.js'; import { Note } from '@/models/entities/note.js';
import { Notes, Users } from '@/models/index.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. * 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, id: noteId,
}); });
generateVisibilityQuery(query, me); const note = await visibilityQuery(query, me).getOne();
const note = await query.getOne();
if (note == null) { if (note == null) {
throw new IdentifiableError('9725d0ce-ba28-4dde-95a7-2cbb2c15de24', 'No such note.'); throw new IdentifiableError('9725d0ce-ba28-4dde-95a7-2cbb2c15de24', 'No such note.');

View file

@ -1,7 +1,7 @@
import { readNote } from '@/services/note/read.js'; import { readNote } from '@/services/note/read.js';
import { Antennas, Notes, AntennaNotes } from '@/models/index.js'; import { Antennas, Notes, AntennaNotes } from '@/models/index.js';
import { makePaginationQuery } from '@/server/api/common/make-pagination-query.js'; import { makePaginationQuery } from '@/server/api/common/make-pagination-query.js';
import { generateVisibilityQuery } from '@/server/api/common/generate-visibility-query.js'; import { visibilityQuery } from '@/server/api/common/generate-visibility-query.js';
import { generateMutedUserQuery } from '@/server/api/common/generate-muted-user-query.js'; import { generateMutedUserQuery } from '@/server/api/common/generate-muted-user-query.js';
import { generateBlockedUserQuery } from '@/server/api/common/generate-block-query.js'; import { generateBlockedUserQuery } from '@/server/api/common/generate-block-query.js';
import define from '@/server/api/define.js'; import define from '@/server/api/define.js';
@ -65,11 +65,10 @@ export default define(meta, paramDef, async (ps, user) => {
.leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner') .leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner')
.andWhere('antennaNote.antennaId = :antennaId', { antennaId: antenna.id }); .andWhere('antennaNote.antennaId = :antennaId', { antennaId: antenna.id });
generateVisibilityQuery(query, user);
generateMutedUserQuery(query, user); generateMutedUserQuery(query, user);
generateBlockedUserQuery(query, user); generateBlockedUserQuery(query, user);
const notes = await query const notes = await visibilityQuery(query, user)
.take(ps.limit) .take(ps.limit)
.getMany(); .getMany();

View file

@ -1,7 +1,7 @@
import { ClipNotes, Clips, Notes } from '@/models/index.js'; import { ClipNotes, Clips, Notes } from '@/models/index.js';
import define from '@/server/api/define.js'; import define from '@/server/api/define.js';
import { makePaginationQuery } from '@/server/api/common/make-pagination-query.js'; import { makePaginationQuery } from '@/server/api/common/make-pagination-query.js';
import { generateVisibilityQuery } from '@/server/api/common/generate-visibility-query.js'; import { visibilityQuery } from '@/server/api/common/generate-visibility-query.js';
import { generateMutedUserQuery } from '@/server/api/common/generate-muted-user-query.js'; import { generateMutedUserQuery } from '@/server/api/common/generate-muted-user-query.js';
import { ApiError } from '@/server/api/error.js'; import { ApiError } from '@/server/api/error.js';
import { generateBlockedUserQuery } from '@/server/api/common/generate-block-query.js'; import { generateBlockedUserQuery } from '@/server/api/common/generate-block-query.js';
@ -65,12 +65,11 @@ export default define(meta, paramDef, async (ps, user) => {
.andWhere('clipNote.clipId = :clipId', { clipId: clip.id }); .andWhere('clipNote.clipId = :clipId', { clipId: clip.id });
if (user) { if (user) {
generateVisibilityQuery(query, user);
generateMutedUserQuery(query, user); generateMutedUserQuery(query, user);
generateBlockedUserQuery(query, user); generateBlockedUserQuery(query, user);
} }
const notes = await query const notes = await visibilityQuery(query, user)
.take(ps.limit) .take(ps.limit)
.getMany(); .getMany();

View file

@ -1,7 +1,7 @@
import { Notes } from '@/models/index.js'; import { Notes } from '@/models/index.js';
import define from '@/server/api/define.js'; import define from '@/server/api/define.js';
import { makePaginationQuery } from '@/server/api/common/make-pagination-query.js'; import { makePaginationQuery } from '@/server/api/common/make-pagination-query.js';
import { generateVisibilityQuery } from '@/server/api/common/generate-visibility-query.js'; import { visibilityQuery } from '@/server/api/common/generate-visibility-query.js';
import { generateMutedUserQuery } from '@/server/api/common/generate-muted-user-query.js'; import { generateMutedUserQuery } from '@/server/api/common/generate-muted-user-query.js';
import { generateBlockedUserQuery } from '@/server/api/common/generate-block-query.js'; import { generateBlockedUserQuery } from '@/server/api/common/generate-block-query.js';
@ -59,13 +59,12 @@ export default define(meta, paramDef, async (ps, user) => {
.andWhere('note.id IN (SELECT id FROM note_replies(:noteId, :depth, :limit))', { noteId: ps.noteId, depth: ps.depth, limit: ps.limit }) .andWhere('note.id IN (SELECT id FROM note_replies(:noteId, :depth, :limit))', { noteId: ps.noteId, depth: ps.depth, limit: ps.limit })
.innerJoinAndSelect('note.user', 'user'); .innerJoinAndSelect('note.user', 'user');
generateVisibilityQuery(query, user);
if (user) { if (user) {
generateMutedUserQuery(query, user); generateMutedUserQuery(query, user);
generateBlockedUserQuery(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 }); return await Notes.packMany(notes, user, { detail: false });
}); });

View file

@ -5,7 +5,7 @@ import { activeUsersChart } from '@/services/chart/index.js';
import define from '@/server/api/define.js'; import define from '@/server/api/define.js';
import { ApiError } from '@/server/api/error.js'; import { ApiError } from '@/server/api/error.js';
import { makePaginationQuery } from '@/server/api/common/make-pagination-query.js'; import { makePaginationQuery } from '@/server/api/common/make-pagination-query.js';
import { generateVisibilityQuery } from '@/server/api/common/generate-visibility-query.js'; import { visibilityQuery } from '@/server/api/common/generate-visibility-query.js';
import { generateMutedUserQuery } from '@/server/api/common/generate-muted-user-query.js'; import { generateMutedUserQuery } from '@/server/api/common/generate-muted-user-query.js';
import { generateRepliesQuery } from '@/server/api/common/generate-replies-query.js'; import { generateRepliesQuery } from '@/server/api/common/generate-replies-query.js';
import { generateMutedNoteQuery } from '@/server/api/common/generate-muted-note-query.js'; import { generateMutedNoteQuery } from '@/server/api/common/generate-muted-note-query.js';
@ -84,7 +84,6 @@ export default define(meta, paramDef, async (ps, user) => {
generateChannelQuery(query, user); generateChannelQuery(query, user);
generateRepliesQuery(query, user); generateRepliesQuery(query, user);
generateVisibilityQuery(query, user);
generateMutedUserQuery(query, user); generateMutedUserQuery(query, user);
generateMutedNoteQuery(query, user); generateMutedNoteQuery(query, user);
generateBlockedUserQuery(query, user); generateBlockedUserQuery(query, user);
@ -125,7 +124,7 @@ export default define(meta, paramDef, async (ps, user) => {
} }
//#endregion //#endregion
const timeline = await query.take(ps.limit).getMany(); const timeline = await visibilityQuery(query, user).take(ps.limit).getMany();
process.nextTick(() => { process.nextTick(() => {
activeUsersChart.read(user); activeUsersChart.read(user);

View file

@ -6,7 +6,7 @@ import define from '@/server/api/define.js';
import { ApiError } from '@/server/api/error.js'; import { ApiError } from '@/server/api/error.js';
import { generateMutedUserQuery } from '@/server/api/common/generate-muted-user-query.js'; import { generateMutedUserQuery } from '@/server/api/common/generate-muted-user-query.js';
import { makePaginationQuery } from '@/server/api/common/make-pagination-query.js'; import { makePaginationQuery } from '@/server/api/common/make-pagination-query.js';
import { generateVisibilityQuery } from '@/server/api/common/generate-visibility-query.js'; import { visibilityQuery } from '@/server/api/common/generate-visibility-query.js';
import { generateRepliesQuery } from '@/server/api/common/generate-replies-query.js'; import { generateRepliesQuery } from '@/server/api/common/generate-replies-query.js';
import { generateMutedNoteQuery } from '@/server/api/common/generate-muted-note-query.js'; import { generateMutedNoteQuery } from '@/server/api/common/generate-muted-note-query.js';
import { generateChannelQuery } from '@/server/api/common/generate-channel-query.js'; import { generateChannelQuery } from '@/server/api/common/generate-channel-query.js';
@ -77,7 +77,6 @@ export default define(meta, paramDef, async (ps, user) => {
generateChannelQuery(query, user); generateChannelQuery(query, user);
generateRepliesQuery(query, user); generateRepliesQuery(query, user);
generateVisibilityQuery(query, user);
if (user) generateMutedUserQuery(query, user); if (user) generateMutedUserQuery(query, user);
if (user) generateMutedNoteQuery(query, user); if (user) generateMutedNoteQuery(query, user);
if (user) generateBlockedUserQuery(query, user); if (user) generateBlockedUserQuery(query, user);
@ -103,7 +102,7 @@ export default define(meta, paramDef, async (ps, user) => {
} }
//#endregion //#endregion
const timeline = await query.take(ps.limit).getMany(); const timeline = await visibilityQuery(query, user).take(ps.limit).getMany();
process.nextTick(() => { process.nextTick(() => {
if (user) { if (user) {

View file

@ -3,7 +3,7 @@ import { noteVisibilities } from 'foundkey-js';
import { readNote } from '@/services/note/read.js'; import { readNote } from '@/services/note/read.js';
import { Notes, Followings } from '@/models/index.js'; import { Notes, Followings } from '@/models/index.js';
import define from '@/server/api/define.js'; import define from '@/server/api/define.js';
import { generateVisibilityQuery } from '@/server/api/common/generate-visibility-query.js'; import { visibilityQuery } from '@/server/api/common/generate-visibility-query.js';
import { generateMutedUserQuery } from '@/server/api/common/generate-muted-user-query.js'; import { generateMutedUserQuery } from '@/server/api/common/generate-muted-user-query.js';
import { makePaginationQuery } from '@/server/api/common/make-pagination-query.js'; import { makePaginationQuery } from '@/server/api/common/make-pagination-query.js';
import { generateBlockedUserQuery } from '@/server/api/common/generate-block-query.js'; import { generateBlockedUserQuery } from '@/server/api/common/generate-block-query.js';
@ -63,7 +63,6 @@ export default define(meta, paramDef, async (ps, user) => {
.leftJoinAndSelect('renoteUser.avatar', 'renoteUserAvatar') .leftJoinAndSelect('renoteUser.avatar', 'renoteUserAvatar')
.leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner'); .leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner');
generateVisibilityQuery(query, user);
generateMutedUserQuery(query, user); generateMutedUserQuery(query, user);
generateMutedNoteThreadQuery(query, user); generateMutedNoteThreadQuery(query, user);
generateBlockedUserQuery(query, user); generateBlockedUserQuery(query, user);
@ -77,7 +76,7 @@ export default define(meta, paramDef, async (ps, user) => {
query.setParameters(followingQuery.getParameters()); 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); readNote(user.id, mentions);

View file

@ -2,7 +2,7 @@ import { Notes } from '@/models/index.js';
import define from '@/server/api/define.js'; import define from '@/server/api/define.js';
import { getNote } from '@/server/api/common/getters.js'; import { getNote } from '@/server/api/common/getters.js';
import { ApiError } from '@/server/api/error.js'; import { ApiError } from '@/server/api/error.js';
import { generateVisibilityQuery } from '@/server/api/common/generate-visibility-query.js'; import { visibilityQuery } from '@/server/api/common/generate-visibility-query.js';
import { generateMutedUserQuery } from '@/server/api/common/generate-muted-user-query.js'; import { generateMutedUserQuery } from '@/server/api/common/generate-muted-user-query.js';
import { makePaginationQuery } from '@/server/api/common/make-pagination-query.js'; import { makePaginationQuery } from '@/server/api/common/make-pagination-query.js';
import { generateBlockedUserQuery } from '@/server/api/common/generate-block-query.js'; import { generateBlockedUserQuery } from '@/server/api/common/generate-block-query.js';
@ -63,11 +63,10 @@ export default define(meta, paramDef, async (ps, user) => {
.leftJoinAndSelect('renoteUser.avatar', 'renoteUserAvatar') .leftJoinAndSelect('renoteUser.avatar', 'renoteUserAvatar')
.leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner'); .leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner');
generateVisibilityQuery(query, user);
if (user) generateMutedUserQuery(query, user); if (user) generateMutedUserQuery(query, user);
if (user) generateBlockedUserQuery(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); return await Notes.packMany(renotes, user);
}); });

View file

@ -2,7 +2,7 @@ import { Notes } from '@/models/index.js';
import { ApiError } from '@/server/api/error.js'; import { ApiError } from '@/server/api/error.js';
import define from '@/server/api/define.js'; import define from '@/server/api/define.js';
import { makePaginationQuery } from '@/server/api/common/make-pagination-query.js'; import { makePaginationQuery } from '@/server/api/common/make-pagination-query.js';
import { generateVisibilityQuery } from '@/server/api/common/generate-visibility-query.js'; import { visibilityQuery } from '@/server/api/common/generate-visibility-query.js';
import { generateMutedUserQuery } from '@/server/api/common/generate-muted-user-query.js'; import { generateMutedUserQuery } from '@/server/api/common/generate-muted-user-query.js';
import { generateBlockedUserQuery } from '@/server/api/common/generate-block-query.js'; import { generateBlockedUserQuery } from '@/server/api/common/generate-block-query.js';
import { getNote } from '@/server/api/common/getters.js'; import { getNote } from '@/server/api/common/getters.js';
@ -63,11 +63,10 @@ export default define(meta, paramDef, async (ps, user) => {
.leftJoinAndSelect('renoteUser.avatar', 'renoteUserAvatar') .leftJoinAndSelect('renoteUser.avatar', 'renoteUserAvatar')
.leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner'); .leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner');
generateVisibilityQuery(query, user);
if (user) generateMutedUserQuery(query, user); if (user) generateMutedUserQuery(query, user);
if (user) generateBlockedUserQuery(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); return await Notes.packMany(timeline, user);
}); });

View file

@ -4,7 +4,7 @@ import { normalizeForSearch } from '@/misc/normalize-for-search.js';
import define from '@/server/api/define.js'; import define from '@/server/api/define.js';
import { makePaginationQuery } from '@/server/api/common/make-pagination-query.js'; import { makePaginationQuery } from '@/server/api/common/make-pagination-query.js';
import { generateMutedUserQuery } from '@/server/api/common/generate-muted-user-query.js'; import { generateMutedUserQuery } from '@/server/api/common/generate-muted-user-query.js';
import { generateVisibilityQuery } from '@/server/api/common/generate-visibility-query.js'; import { visibilityQuery } from '@/server/api/common/generate-visibility-query.js';
import { generateBlockedUserQuery } from '@/server/api/common/generate-block-query.js'; import { generateBlockedUserQuery } from '@/server/api/common/generate-block-query.js';
export const meta = { export const meta = {
@ -79,7 +79,6 @@ export default define(meta, paramDef, async (ps, me) => {
.leftJoinAndSelect('renoteUser.avatar', 'renoteUserAvatar') .leftJoinAndSelect('renoteUser.avatar', 'renoteUserAvatar')
.leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner'); .leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner');
generateVisibilityQuery(query, me);
if (me) generateMutedUserQuery(query, me); if (me) generateMutedUserQuery(query, me);
if (me) generateBlockedUserQuery(query, me); if (me) generateBlockedUserQuery(query, me);
@ -132,7 +131,7 @@ export default define(meta, paramDef, async (ps, me) => {
} }
// Search notes // 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); return await Notes.packMany(notes, me);
}); });

View file

@ -4,7 +4,7 @@ import config from '@/config/index.js';
import es from '@/db/elasticsearch.js'; import es from '@/db/elasticsearch.js';
import define from '@/server/api/define.js'; import define from '@/server/api/define.js';
import { makePaginationQuery } from '@/server/api/common/make-pagination-query.js'; import { makePaginationQuery } from '@/server/api/common/make-pagination-query.js';
import { generateVisibilityQuery } from '@/server/api/common/generate-visibility-query.js'; import { visibilityQuery } from '@/server/api/common/generate-visibility-query.js';
import { generateMutedUserQuery } from '@/server/api/common/generate-muted-user-query.js'; import { generateMutedUserQuery } from '@/server/api/common/generate-muted-user-query.js';
import { generateBlockedUserQuery } from '@/server/api/common/generate-block-query.js'; import { generateBlockedUserQuery } from '@/server/api/common/generate-block-query.js';
@ -70,11 +70,10 @@ export default define(meta, paramDef, async (ps, me) => {
.leftJoinAndSelect('renoteUser.avatar', 'renoteUserAvatar') .leftJoinAndSelect('renoteUser.avatar', 'renoteUserAvatar')
.leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner'); .leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner');
generateVisibilityQuery(query, me);
if (me) generateMutedUserQuery(query, me); if (me) generateMutedUserQuery(query, me);
if (me) generateBlockedUserQuery(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); return await Notes.packMany(notes, me);
} else { } else {

View file

@ -3,7 +3,7 @@ import { Notes, Followings } from '@/models/index.js';
import { activeUsersChart } from '@/services/chart/index.js'; import { activeUsersChart } from '@/services/chart/index.js';
import define from '@/server/api/define.js'; import define from '@/server/api/define.js';
import { makePaginationQuery } from '@/server/api/common/make-pagination-query.js'; import { makePaginationQuery } from '@/server/api/common/make-pagination-query.js';
import { generateVisibilityQuery } from '@/server/api/common/generate-visibility-query.js'; import { visibilityQuery } from '@/server/api/common/generate-visibility-query.js';
import { generateMutedUserQuery } from '@/server/api/common/generate-muted-user-query.js'; import { generateMutedUserQuery } from '@/server/api/common/generate-muted-user-query.js';
import { generateRepliesQuery } from '@/server/api/common/generate-replies-query.js'; import { generateRepliesQuery } from '@/server/api/common/generate-replies-query.js';
import { generateMutedNoteQuery } from '@/server/api/common/generate-muted-note-query.js'; import { generateMutedNoteQuery } from '@/server/api/common/generate-muted-note-query.js';
@ -82,7 +82,6 @@ export default define(meta, paramDef, async (ps, user) => {
generateChannelQuery(query, user); generateChannelQuery(query, user);
generateRepliesQuery(query, user); generateRepliesQuery(query, user);
generateVisibilityQuery(query, user);
generateMutedUserQuery(query, user); generateMutedUserQuery(query, user);
generateMutedNoteQuery(query, user); generateMutedNoteQuery(query, user);
generateBlockedUserQuery(query, user); generateBlockedUserQuery(query, user);
@ -123,7 +122,7 @@ export default define(meta, paramDef, async (ps, user) => {
} }
//#endregion //#endregion
const timeline = await query.take(ps.limit).getMany(); const timeline = await visibilityQuery(query, user).take(ps.limit).getMany();
process.nextTick(() => { process.nextTick(() => {
activeUsersChart.read(user); activeUsersChart.read(user);

View file

@ -4,7 +4,7 @@ import { activeUsersChart } from '@/services/chart/index.js';
import define from '@/server/api/define.js'; import define from '@/server/api/define.js';
import { ApiError } from '@/server/api/error.js'; import { ApiError } from '@/server/api/error.js';
import { makePaginationQuery } from '@/server/api/common/make-pagination-query.js'; import { makePaginationQuery } from '@/server/api/common/make-pagination-query.js';
import { generateVisibilityQuery } from '@/server/api/common/generate-visibility-query.js'; import { visibilityQuery } from '@/server/api/common/generate-visibility-query.js';
export const meta = { export const meta = {
tags: ['notes', 'lists'], tags: ['notes', 'lists'],
@ -70,8 +70,6 @@ export default define(meta, paramDef, async (ps, user) => {
.leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner') .leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner')
.andWhere('userListJoining.userListId = :userListId', { userListId: list.id }); .andWhere('userListJoining.userListId = :userListId', { userListId: list.id });
generateVisibilityQuery(query, user);
if (ps.includeMyRenotes === false) { if (ps.includeMyRenotes === false) {
query.andWhere(new Brackets(qb => { query.andWhere(new Brackets(qb => {
qb.orWhere('note.userId != :meId', { meId: user.id }); qb.orWhere('note.userId != :meId', { meId: user.id });
@ -107,7 +105,7 @@ export default define(meta, paramDef, async (ps, user) => {
} }
//#endregion //#endregion
const timeline = await query.take(ps.limit).getMany(); const timeline = await visibilityQuery(query, user).take(ps.limit).getMany();
activeUsersChart.read(user); activeUsersChart.read(user);

View file

@ -4,7 +4,7 @@ import define from '@/server/api/define.js';
import { ApiError } from '@/server/api/error.js'; import { ApiError } from '@/server/api/error.js';
import { getUser } from '@/server/api/common/getters.js'; import { getUser } from '@/server/api/common/getters.js';
import { makePaginationQuery } from '@/server/api/common/make-pagination-query.js'; import { makePaginationQuery } from '@/server/api/common/make-pagination-query.js';
import { generateVisibilityQuery } from '@/server/api/common/generate-visibility-query.js'; import { visibilityQuery } from '@/server/api/common/generate-visibility-query.js';
import { generateMutedUserQuery } from '@/server/api/common/generate-muted-user-query.js'; import { generateMutedUserQuery } from '@/server/api/common/generate-muted-user-query.js';
import { generateBlockedUserQuery } from '@/server/api/common/generate-block-query.js'; import { generateBlockedUserQuery } from '@/server/api/common/generate-block-query.js';
@ -69,7 +69,6 @@ export default define(meta, paramDef, async (ps, me) => {
.leftJoinAndSelect('renoteUser.avatar', 'renoteUserAvatar') .leftJoinAndSelect('renoteUser.avatar', 'renoteUserAvatar')
.leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner'); .leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner');
generateVisibilityQuery(query, me);
if (me) { if (me) {
generateMutedUserQuery(query, me); generateMutedUserQuery(query, me);
generateBlockedUserQuery(query, me); generateBlockedUserQuery(query, me);
@ -110,7 +109,7 @@ export default define(meta, paramDef, async (ps, me) => {
//#endregion //#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); return await Notes.packMany(timeline, me);
}); });

View file

@ -1,7 +1,7 @@
import { NoteReactions, UserProfiles } from '@/models/index.js'; import { NoteReactions, UserProfiles } from '@/models/index.js';
import define from '@/server/api/define.js'; import define from '@/server/api/define.js';
import { makePaginationQuery } from '@/server/api/common/make-pagination-query.js'; import { makePaginationQuery } from '@/server/api/common/make-pagination-query.js';
import { generateVisibilityQuery } from '@/server/api/common/generate-visibility-query.js'; import { visibilityQuery } from '@/server/api/common/generate-visibility-query.js';
import { ApiError } from '@/server/api/error.js'; import { ApiError } from '@/server/api/error.js';
export const meta = { export const meta = {
@ -50,9 +50,7 @@ export default define(meta, paramDef, async (ps, me) => {
.andWhere('reaction.userId = :userId', { userId: ps.userId }) .andWhere('reaction.userId = :userId', { userId: ps.userId })
.leftJoinAndSelect('reaction.note', 'note'); .leftJoinAndSelect('reaction.note', 'note');
generateVisibilityQuery(query, me); const reactions = await visibilityQuery(query, me)
const reactions = await query
.take(ps.limit) .take(ps.limit)
.getMany(); .getMany();