fix(telegram): guard voice note sends

This commit is contained in:
Jarvis
2026-01-08 13:55:36 +00:00
committed by Peter Steinberger
parent 2f036f7173
commit ce786762db
4 changed files with 75 additions and 2 deletions

15
src/telegram/voice.ts Normal file
View File

@@ -0,0 +1,15 @@
import path from "node:path";
export function isTelegramVoiceCompatible(opts: {
contentType?: string | null;
fileName?: string | null;
}): boolean {
const mime = opts.contentType?.toLowerCase();
if (mime && (mime.includes("ogg") || mime.includes("opus"))) {
return true;
}
const fileName = opts.fileName?.trim();
if (!fileName) return false;
const ext = path.extname(fileName).toLowerCase();
return ext === ".ogg" || ext === ".opus" || ext === ".oga";
}