2023-01-12 21:40:33 -07:00
|
|
|
import type { User } from "@/models/entities/user.js";
|
|
|
|
import { MutedNotes } from "@/models/index.js";
|
|
|
|
import type { SelectQueryBuilder } from "typeorm";
|
2020-07-26 22:34:20 -06:00
|
|
|
|
2023-01-12 21:40:33 -07:00
|
|
|
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 });
|
2020-07-26 22:34:20 -06:00
|
|
|
|
2023-01-12 21:40:33 -07:00
|
|
|
q.andWhere(`note.id NOT IN (${mutedQuery.getQuery()})`);
|
2020-07-26 22:34:20 -06:00
|
|
|
|
|
|
|
q.setParameters(mutedQuery.getParameters());
|
|
|
|
}
|