feat(moderation): improve message analysis scheduling and update moderation prompt structure

This commit is contained in:
MythEclipse
2026-05-21 02:56:41 +07:00
parent 7eb01606b7
commit c1c3c99686
4 changed files with 28 additions and 25 deletions
+5
View File
@@ -91,6 +91,7 @@ async function processBatch(
if (messages.length === 0) return;
activeRequests++;
let shouldScheduleNext = false;
const processingStartedAt = Date.now();
conversationProcessing.set(conversationKey, processingStartedAt);
try {
@@ -123,6 +124,7 @@ async function processBatch(
}
conversationErrorCooldown.delete(conversationKey);
shouldScheduleNext = true;
} catch (error) {
lastError = error instanceof Error ? error.message : String(error);
const errorStack = error instanceof Error ? error.stack : undefined;
@@ -149,6 +151,9 @@ async function processBatch(
if (conversationProcessing.get(conversationKey) === processingStartedAt) {
conversationProcessing.delete(conversationKey);
}
if (shouldScheduleNext) {
setImmediate(() => scheduleConversationAnalysis(conversationKey));
}
}
}