cases: add safeguard check for existing cases with the same audit log id

This commit is contained in:
Dragory 2020-06-04 02:37:13 +03:00
parent 69db410808
commit ff9bcca350
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1

View file

@ -94,6 +94,14 @@ export class CasesPlugin extends ZeppelinPlugin<TConfigSchema> {
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,