feat(ai-moderation): use per-server nickname (displayName) in analysis payload

- resolveDisplayName(): member.displayName from captured metadata,
  falls back to global username
- Applied to context lines, target message blocks, and media message
  blocks — LLM sees the name the channel actually sees (nickname can
  carry moderation signal itself)
This commit is contained in:
asepharyana
2026-08-10 11:36:37 +07:00
parent 4049ab4201
commit ecbb538c9f
5 changed files with 52 additions and 3 deletions
@@ -39,6 +39,7 @@ import {
buildReferenceXml,
escapeXml,
getAnalysisContent,
resolveDisplayName,
} from "./moderationBuilders.js";
import {
buildCustomEmojiVisionPrompt,
@@ -367,6 +368,6 @@ export async function prepareMediaMessage(
const profile = await getUserProfile(target.user_id);
const refXml = await buildReferenceXml(target);
const messageBlock = `<message id="${escapeXml(target.id)}" user="${escapeXml(target.username)}">\n <user_reputation trust_score="${rep.trust_score}" />${profile ? `\n <user_profile>${sanitizeAiContent(profile.profile_summary)}</user_profile>` : ""}${refXml ? `\n ${refXml}` : ""}\n <content>${escapeXml(content)}</content>${mediaContext ? ` ${escapeXml(mediaContext)}` : ""}${webContext}${mediaAnalysisContext}${searxngXml}\n</message>`;
const messageBlock = `<message id="${escapeXml(target.id)}" user="${escapeXml(resolveDisplayName(target))}">\n <user_reputation trust_score="${rep.trust_score}" />${profile ? `\n <user_profile>${sanitizeAiContent(profile.profile_summary)}</user_profile>` : ""}${refXml ? `\n ${refXml}` : ""}\n <content>${escapeXml(content)}</content>${mediaContext ? ` ${escapeXml(mediaContext)}` : ""}${webContext}${mediaAnalysisContext}${searxngXml}\n</message>`;
return { targetId, messageBlock };
}