fix(ai-moderation): use cached status instead of hardcoding "clean" for cache hit results
This commit is contained in:
@@ -1687,7 +1687,7 @@ export async function runModerationAnalysis(
|
|||||||
if (cached) {
|
if (cached) {
|
||||||
cacheHits.push({
|
cacheHits.push({
|
||||||
messageId: target.id,
|
messageId: target.id,
|
||||||
status: "clean",
|
status: cached.status,
|
||||||
flags: cached.flags,
|
flags: cached.flags,
|
||||||
score: cached.score,
|
score: cached.score,
|
||||||
analysis: cached.analysis,
|
analysis: cached.analysis,
|
||||||
@@ -1776,6 +1776,7 @@ export async function runModerationAnalysis(
|
|||||||
severity: result.severity ?? "none",
|
severity: result.severity ?? "none",
|
||||||
confidence: result.confidence ?? result.score ?? 0,
|
confidence: result.confidence ?? result.score ?? 0,
|
||||||
recommendedAction: result.recommendedAction ?? "none",
|
recommendedAction: result.recommendedAction ?? "none",
|
||||||
|
status: result.status === "error" ? "flagged" : result.status,
|
||||||
}).catch(() => {});
|
}).catch(() => {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -332,6 +332,7 @@ export async function setCachedUserModeration(
|
|||||||
severity: string;
|
severity: string;
|
||||||
confidence: number;
|
confidence: number;
|
||||||
recommendedAction: string;
|
recommendedAction: string;
|
||||||
|
status?: "clean" | "warn" | "flagged";
|
||||||
},
|
},
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
|
|||||||
Reference in New Issue
Block a user