import { Notes } from "../models/index.js"; export async function countSameRenotes(userId, renoteId, excludeNoteId, groupId) { // 指定したユーザーの指定したノートのリノートがいくつあるか数える const query = Notes.createQueryBuilder("note").where("note.userId = :userId", { userId }).andWhere("note.renoteId = :renoteId", { renoteId }); if (groupId) { query.andWhere("note.groupId = :groupId", { groupId }); } else { query.andWhere("note.groupId IS NULL"); } // 指定した投稿を除く if (excludeNoteId) { query.andWhere("note.id != :excludeNoteId", { excludeNoteId }); } return await query.getCount(); }