iceshrimp-legacy/packages/backend/src/misc/count-same-renotes.ts

16 lines
575 B
TypeScript
Raw Normal View History

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