From f6c376f20d826cc551293ae67292ad0ba7152fab Mon Sep 17 00:00:00 2001 From: Oni-Men Date: Wed, 26 Feb 2020 07:54:35 +0900 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E3=81=98=E3=83=8E=E3=83=BC=E3=83=88?= =?UTF-8?q?=E3=82=92=E4=BD=95=E5=9B=9E=E3=83=AA=E3=83=8E=E3=83=BC=E3=83=88?= =?UTF-8?q?=E3=81=97=E3=81=A6=E3=82=82=E4=B8=80=E5=9B=9E=E3=81=A8=E3=81=97?= =?UTF-8?q?=E3=81=A6=E6=95=B0=E3=81=88=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=20(#6086)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 同じノートを何回リノートしても一回として数えるように * Update count-same-renotes.ts Co-authored-by: syuilo --- src/services/count-same-renotes.ts | 15 +++++++++++++++ src/services/note/create.ts | 4 +++- src/services/note/delete.ts | 4 +++- 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 src/services/count-same-renotes.ts diff --git a/src/services/count-same-renotes.ts b/src/services/count-same-renotes.ts new file mode 100644 index 0000000000..a20b4fbf8c --- /dev/null +++ b/src/services/count-same-renotes.ts @@ -0,0 +1,15 @@ +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 3426083e30..98b1731802 100644 --- a/src/services/note/create.ts +++ b/src/services/note/create.ts @@ -30,6 +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'; type NotificationType = 'reply' | 'renote' | 'quote' | 'mention'; @@ -236,7 +237,8 @@ export default async (user: User, data: Option, silent = false) => new Promise