From fcb199a6aecbee994b5eee87b901d0156cb2574a Mon Sep 17 00:00:00 2001 From: MythEclipse Date: Fri, 12 Jun 2026 17:07:34 +0700 Subject: [PATCH] fix(capture): exclude threads inside excluded channels - Resolve parent channel ID for threads before checking EXCLUDED_CHANNEL_IDS set - Thread messages now blocked if their parent channel is excluded Co-Authored-By: Claude --- .../modules/message-capture/messageCapture.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/services/discord-gateway/src/modules/message-capture/messageCapture.ts b/services/discord-gateway/src/modules/message-capture/messageCapture.ts index c9deb6b..775892e 100644 --- a/services/discord-gateway/src/modules/message-capture/messageCapture.ts +++ b/services/discord-gateway/src/modules/message-capture/messageCapture.ts @@ -47,12 +47,27 @@ const EXCLUDED_CHANNEL_IDS = new Set([ "1323365288447574128", ]); +function getParentChannelId( + message: MessageLocationInput, +): string | null | undefined { + try { + const m = message as { + channel?: { isThread?: () => boolean; parentId?: string }; + }; + if (m.channel?.isThread?.() && m.channel.parentId) + return m.channel.parentId; + } catch { + // Not a thread or can't resolve — fall back to channelId + } + return null; +} + export function shouldCaptureMessageLocation( message: MessageLocationInput, target: TextCaptureTarget, ): boolean { - if (message.channelId && EXCLUDED_CHANNEL_IDS.has(message.channelId)) - return false; + const effectiveId = getParentChannelId(message) ?? message.channelId; + if (effectiveId && EXCLUDED_CHANNEL_IDS.has(effectiveId)) return false; if (!message.guildId || message.guildId !== target.guildId) return false; if (target.channelId && message.channelId !== target.channelId) return false; return true;