fix: harden discord audio preflight mention detection (#32136) (thanks @jnMetaCode)

This commit is contained in:
Peter Steinberger
2026-03-02 22:41:18 +00:00
parent b9b47f5002
commit 0b5d8e5b47
3 changed files with 109 additions and 3 deletions

View File

@@ -504,11 +504,13 @@ export async function preflightDiscordMessage(
const hasAudioAttachment = message.attachments?.some((att: { content_type?: string }) =>
att.content_type?.startsWith("audio/"),
);
const hasTypedText = Boolean(message.content?.trim());
const needsPreflightTranscription =
!isDirectMessage &&
shouldRequireMention &&
hasAudioAttachment &&
!baseText &&
// `baseText` includes media placeholders; gate on typed text only.
!hasTypedText &&
mentionRegexes.length > 0;
if (needsPreflightTranscription) {
@@ -541,10 +543,11 @@ export async function preflightDiscordMessage(
}
}
const mentionText = hasTypedText ? baseText : "";
const wasMentioned =
!isDirectMessage &&
matchesMentionWithExplicit({
text: baseText,
text: mentionText,
mentionRegexes,
explicit: {
hasAnyMention,