Files
2026-07-26 18:25:37 +09:00

24 lines
764 B
JavaScript

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();
}