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