From ff9bcca3502fb28895281ab5219e31f65b351edd Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Thu, 4 Jun 2020 02:37:13 +0300 Subject: [PATCH] cases: add safeguard check for existing cases with the same audit log id --- backend/src/plugins/Cases.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/backend/src/plugins/Cases.ts b/backend/src/plugins/Cases.ts index 98e30c7c..530dcc9e 100644 --- a/backend/src/plugins/Cases.ts +++ b/backend/src/plugins/Cases.ts @@ -94,6 +94,14 @@ export class CasesPlugin extends ZeppelinPlugin { ppName = `${pp.username}#${pp.discriminator}`; } + if (args.auditLogId) { + const existingAuditLogCase = await this.cases.findByAuditLogId(args.auditLogId); + if (existingAuditLogCase) { + delete args.auditLogId; + logger.warn(`Duplicate audit log ID for mod case: ${args.auditLogId}`); + } + } + const createdCase = await this.cases.create({ type: args.type, user_id: args.userId,