From 7121bdef6b232294acda25b169be1e008a8812b6 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 26 Feb 2020 07:56:32 +0900 Subject: Refactor --- src/misc/count-same-renotes.ts | 15 +++++++++++++++ src/services/count-same-renotes.ts | 15 --------------- src/services/note/create.ts | 4 ++-- src/services/note/delete.ts | 4 ++-- 4 files changed, 19 insertions(+), 19 deletions(-) create mode 100644 src/misc/count-same-renotes.ts delete mode 100644 src/services/count-same-renotes.ts diff --git a/src/misc/count-same-renotes.ts b/src/misc/count-same-renotes.ts new file mode 100644 index 0000000000..0233bdf88e --- /dev/null +++ b/src/misc/count-same-renotes.ts @@ -0,0 +1,15 @@ +import { Notes } from '../models'; + +export async function countSameRenotes(userId: string, renoteId: string, excludeNoteId: string | undefined): Promise { + // 指定したユーザーの指定したノートのリノートがいくつあるか数える + const query = Notes.createQueryBuilder('note') + .where('note.userId = :userId', { userId }) + .andWhere('note.renoteId = :renoteId', { renoteId }) + + // 指定した投稿を除く + if (excludeNoteId) { + query.andWhere('note.id != :excludeNoteId', { excludeNoteId }) + } + + return await query.getCount(); +} diff --git a/src/services/count-same-renotes.ts b/src/services/count-same-renotes.ts deleted file mode 100644 index a20b4fbf8c..0000000000 --- a/src/services/count-same-renotes.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Notes } from '../models'; - -export default async function(userId: string, renoteId: string, excludeNoteId: string | undefined): Promise { - // 指定したユーザーの指定したノートのリノートがいくつあるか数える - const query = Notes.createQueryBuilder('note') - .where('note.userId = :userId', { userId }) - .andWhere('note.renoteId = :renoteId', { renoteId }) - - // 指定した投稿を除く - if (excludeNoteId) { - query.andWhere('note.id != :excludeNoteId', { excludeNoteId }) - } - - return await query.getCount(); -} diff --git a/src/services/note/create.ts b/src/services/note/create.ts index 98b1731802..a10ee5164b 100644 --- a/src/services/note/create.ts +++ b/src/services/note/create.ts @@ -30,7 +30,7 @@ import { isDuplicateKeyValueError } from '../../misc/is-duplicate-key-value-erro import { ensure } from '../../prelude/ensure'; import { checkHitAntenna } from '../../misc/check-hit-antenna'; import { addNoteToAntenna } from '../add-note-to-antenna'; -import countSameRenotes from '../count-same-renotes'; +import { countSameRenotes } from '../../misc/count-same-renotes'; type NotificationType = 'reply' | 'renote' | 'quote' | 'mention'; @@ -237,7 +237,7 @@ export default async (user: User, data: Option, silent = false) => new Promise