jormungandr-bite/packages/backend/src/server/api/common/generate-muted-note-query.ts
syuilo 14148f6c4a refactoring
Resolve #7779
2021-11-12 02:02:25 +09:00

13 lines
482 B
TypeScript

import { User } from '@/models/entities/user';
import { MutedNotes } from '@/models/index';
import { SelectQueryBuilder } from 'typeorm';
export function generateMutedNoteQuery(q: SelectQueryBuilder<any>, me: { id: User['id'] }) {
const mutedQuery = MutedNotes.createQueryBuilder('muted')
.select('muted.noteId')
.where('muted.userId = :userId', { userId: me.id });
q.andWhere(`note.id NOT IN (${ mutedQuery.getQuery() })`);
q.setParameters(mutedQuery.getParameters());
}