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