feat(gateway): capture NSFW/age-restricted messages but skip AI analysis + exclude from public archive

Previously isAgeRestrictedMessage() early-returned in messageCreate/messageUpdate,
so NSFW-channel messages were never stored at all. Now they are captured like
any message (visible in dashboard), while the existing age-restricted skip path
(queueMessageAnalysis -> buildAgeRestrictedSkipResult) marks them clean with flag
age_restricted WITHOUT calling the LLM.

NSFW content is also deliberately kept OUT of the Qdrant public semantic-search
archive (archiveMessageEmbedded skips when isAgeRestricted), so it can't be found
via public web search. No schema change needed (metadata already carries channel.nsfw).
This commit is contained in:
asepharyana authored and asepharyana committed 2026-08-30 20:13:35 +07:00
1 parent 7dfb4035b7
commit 50967f6481
3 files changed
+65 -3

No files matched your search

@@ -215,8 +215,12 @@ export async function captureMessage(
// Fire-and-forget: make the captured message searchable in the persistent
// archive (public semantic search). Never blocks capture/moderation.
// NSFW/age-restricted messages are kept OUT of the public archive.
if (!isBacklog && messageRecord.content) {
archiveMessageEmbedded(messageRecord);
archiveMessageEmbedded({
...messageRecord,
isAgeRestricted: isAgeRestrictedMessage(message),
});
}
if (_eventBroadcaster && !isBacklog) {
@@ -288,7 +292,6 @@ export function registerMessageCapture(client: Client): void {
client.on("messageCreate", async (message) => {
if (!shouldCaptureForAnyTarget(message, targets)) return;
if (isBotExcludedChannel(message)) return;
if (isAgeRestrictedMessage(message)) return;
if (isExcludedThread(message)) return;
try {
@@ -307,7 +310,6 @@ export function registerMessageCapture(client: Client): void {
client.on("messageUpdate", async (_oldMessage, newMessage) => {
if (!shouldCaptureForAnyTarget(newMessage, targets)) return;
if (isBotExcludedChannel(newMessage as Message)) return;
if (isAgeRestrictedMessage(newMessage as Message)) return;
if (isExcludedThread(newMessage)) return;
try {