2021-08-19 21:55:45 +09:00
|
|
|
import { User } from '@/models/entities/user';
|
|
|
|
import { MutedNotes } from '@/models/index';
|
2020-07-27 13:34:20 +09:00
|
|
|
import { SelectQueryBuilder } from 'typeorm';
|
|
|
|
|
2021-03-24 11:05:37 +09:00
|
|
|
export function generateMutedNoteQuery(q: SelectQueryBuilder<any>, me: { id: User['id'] }) {
|
2020-07-27 13:34:20 +09:00
|
|
|
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());
|
|
|
|
}
|