You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
console.log(`[Duplicate Check] Redis GET result for key ${duplicateCheckKey}: ${existingTicketId}`);
427
-
428
-
if(existingTicketId){
429
-
console.log(`[Duplicate Check] Duplicate ticket creation detected for user ${currentUser.id} with title hash ${titleHash}. Returning existing ticket ID: ${existingTicketId}`);
430
-
ctx.status=200;// Or maybe 303 See Other? 200 with flag is likely fine.
431
-
ctx.body={id: existingTicketId,duplicated: true};
432
-
return;// Return early, do not proceed to create ticket
433
-
}
434
-
}catch(error: any){
435
-
console.error(`[Duplicate Check] Redis duplicate check failed for user ${currentUser.id}:`,error);
console.log(`[Duplicate Check] Redis GET result for key ${duplicateCheckKey}: ${existingTicketId}`);
451
+
452
+
if(existingTicketId){
453
+
console.log(`[Duplicate Check] Duplicate ticket detected based on ${checkType} for user ${currentUser.id} with hash ${payloadHash}. Returning existing ID: ${existingTicketId}`);
454
+
ctx.status=200;
455
+
ctx.body={id: existingTicketId,duplicated: true};
456
+
return;// Return early
457
+
}
458
+
}catch(error: any){
459
+
console.error(`[Duplicate Check] Redis GET failed for user ${currentUser.id}, key ${duplicateCheckKey}:`,error);
460
+
// Fail open: If Redis GET fails, allow creation.
461
+
duplicateCheckKey=null;// Prevent SET attempt later
462
+
}
463
+
}else{
464
+
console.warn(`[Duplicate Check] Redis client not available. Skipping Redis GET/SET for user ${currentUser.id}.`);
465
+
duplicateCheckKey=null;// Prevent SET attempt later
466
+
}
442
467
}
443
468
444
469
// Proceed to the actual ticket creation handler
445
470
awaitnext();
446
471
447
472
// ---- After ticket creation ----
448
-
// Check if ticket creation was successful and we have an ID to store
449
473
constcreatedTicketId=(ctx.bodyasany)?.id;
450
-
constwasSuccessful=ctx.status===201&&createdTicketId;// Assuming 201 Created is success status
console.error(`[Duplicate Set] Redis SET failed for ticket ${createdTicketId}, key ${duplicateCheckKey}:`,error);
460
487
// Log error but don't block response
461
488
}
462
489
}elseif(wasSuccessful&&!redis){
463
-
console.warn(`[Duplicate Set] Redis client not available. Cannot store duplicate check key for new ticket ${createdTicketId}.`);
490
+
console.warn(`[Duplicate Set] Redis client not available. Cannot store duplicate check key for new ticket ${createdTicketId}.`);
464
491
}elseif(wasSuccessful&&!duplicateCheckKey){
465
-
console.warn(`[Duplicate Set] Duplicate check key was not generated (likely due to earlier Redis error). Cannot store for new ticket ${createdTicketId}.`);
492
+
console.warn(`[Duplicate Set] Duplicate check key was not generated/used. Cannot store for new ticket ${createdTicketId}.`);
0 commit comments