refactor(moderation): clean up code formatting for improved readability

This commit is contained in:
MythEclipse
2026-05-31 22:05:50 +07:00
parent 331076a540
commit 96cd0cfc62
+6 -11
View File
@@ -481,8 +481,7 @@ function hasMediaContent(
): boolean { ): boolean {
if (target.metadata) { if (target.metadata) {
const evidence = extractMessageMediaEvidence(target.metadata); const evidence = extractMessageMediaEvidence(target.metadata);
if (evidence.stickers.length > 0 || evidence.embeds.length > 0) if (evidence.stickers.length > 0 || evidence.embeds.length > 0) return true;
return true;
} }
if (attachments?.some((a) => a.message_id === target.id)) return true; if (attachments?.some((a) => a.message_id === target.id)) return true;
return false; return false;
@@ -832,7 +831,8 @@ async function runTextOnlyBatch(
const correction = lastParseError const correction = lastParseError
? { ? {
error: lastParseError, error: lastParseError,
preview: (lastInvalidContent as string | null)?.slice(0, 800) ?? "<empty>", preview:
(lastInvalidContent as string | null)?.slice(0, 800) ?? "<empty>",
} }
: undefined; : undefined;
@@ -1061,10 +1061,7 @@ async function runSingleMediaAnalysis(
), ),
]; ];
const remainingSlots = Math.max( const remainingSlots = Math.max(0, 8 - (imageMap.get(targetId)?.length ?? 0));
0,
8 - (imageMap.get(targetId)?.length ?? 0),
);
await Promise.all( await Promise.all(
mediaCandidates.slice(0, remainingSlots).map(async (candidate) => { mediaCandidates.slice(0, remainingSlots).map(async (candidate) => {
@@ -1146,13 +1143,11 @@ async function runSingleMediaAnalysis(
); );
// ── 5. Build single-message prompt ── // ── 5. Build single-message prompt ──
const textEvidence = const textEvidence = await formatModerationTextEvidenceForPrompt(content);
await formatModerationTextEvidenceForPrompt(content);
const webTexts = webTextMap.get(targetId) ?? []; const webTexts = webTextMap.get(targetId) ?? [];
const mediaAnalyses = mediaAnalysisMap.get(targetId) ?? []; const mediaAnalyses = mediaAnalysisMap.get(targetId) ?? [];
const webContext = const webContext = webTexts.length > 0 ? `\n${webTexts.join("\n")}` : "";
webTexts.length > 0 ? `\n${webTexts.join("\n")}` : "";
const textContext = textEvidence ? `\n${textEvidence}` : ""; const textContext = textEvidence ? `\n${textEvidence}` : "";
const mediaAnalysisContext = const mediaAnalysisContext =
mediaAnalyses.length > 0 ? `\n${mediaAnalyses.join("\n")}` : ""; mediaAnalyses.length > 0 ? `\n${mediaAnalyses.join("\n")}` : "";