1
0
mirror of https://github.com/hotomoe/hotomoe synced 2024-12-29 05:58:06 +09:00
hotomoe/packages/backend/src/misc/count-same-renotes.ts

16 lines
578 B
TypeScript
Raw Normal View History

import { Notes } from '@/models/index.js';
2020-02-26 07:56:32 +09: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 17:25:16 +09:00
.andWhere('note.renoteId = :renoteId', { renoteId });
// 指定した投稿を除く
if (excludeNoteId) {
2020-05-10 17:25:16 +09:00
query.andWhere('note.id != :excludeNoteId', { excludeNoteId });
}
return await query.getCount();
}