From 916512fd4713a0a0cf5c46131cb4b41f174228a5 Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Mon, 13 Apr 2020 23:58:38 +0900 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E3=81=98=E3=83=AA=E3=82=A2=E3=82=AF?= =?UTF-8?q?=E3=82=B7=E3=83=A7=E3=83=B3=E5=89=8A=E9=99=A4=E3=82=92=E5=90=8C?= =?UTF-8?q?=E6=99=82=E3=81=AB=E8=A1=8C=E3=81=86=E3=81=A8=E3=83=AA=E3=82=A2?= =?UTF-8?q?=E3=82=AF=E3=82=B7=E3=83=A7=E3=83=B3=E3=82=AB=E3=82=A6=E3=83=B3?= =?UTF-8?q?=E3=83=88=E3=81=8C=E3=81=8A=E3=81=8B=E3=81=97=E3=81=8F=E3=81=AA?= =?UTF-8?q?=E3=82=8B=E3=81=93=E3=81=A8=E3=81=8C=E3=81=82=E3=82=8B=E3=81=AE?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3=20(#6253)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix #6252 * quote * Use IdentifiableError --- src/services/note/reaction/delete.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/services/note/reaction/delete.ts b/src/services/note/reaction/delete.ts index 620856c2d..09566e07b 100644 --- a/src/services/note/reaction/delete.ts +++ b/src/services/note/reaction/delete.ts @@ -20,7 +20,11 @@ export default async (user: User, note: Note) => { } // Delete reaction - await NoteReactions.delete(exist.id); + const result = await NoteReactions.delete(exist.id); + + if (result.affected !== 1) { + throw new IdentifiableError('60527ec9-b4cb-4a88-a6bd-32d3ad26817d', 'not reacted'); + } // Decrement reactions count const sql = `jsonb_set("reactions", '{${exist.reaction}}', (COALESCE("reactions"->>'${exist.reaction}', '0')::int - 1)::text::jsonb)`;