2023-01-13 05:40:33 +01:00
|
|
|
import { Notes } from "@/models/index.js";
|
2020-02-25 23:54:35 +01:00
|
|
|
|
2023-01-13 05:40:33 +01:00
|
|
|
export async function countSameRenotes(
|
|
|
|
userId: string,
|
|
|
|
renoteId: string,
|
|
|
|
excludeNoteId: string | undefined,
|
|
|
|
): Promise<number> {
|
2020-02-25 23:54:35 +01:00
|
|
|
// 指定したユーザーの指定したノートのリノートがいくつあるか数える
|
2023-01-13 05:40:33 +01:00
|
|
|
const query = Notes.createQueryBuilder("note")
|
|
|
|
.where("note.userId = :userId", { userId })
|
|
|
|
.andWhere("note.renoteId = :renoteId", { renoteId });
|
2020-02-25 23:54:35 +01:00
|
|
|
|
|
|
|
// 指定した投稿を除く
|
|
|
|
if (excludeNoteId) {
|
2023-01-13 05:40:33 +01:00
|
|
|
query.andWhere("note.id != :excludeNoteId", { excludeNoteId });
|
2020-02-25 23:54:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return await query.getCount();
|
|
|
|
}
|