refactor: unify inline directives and media fetch

This commit is contained in:
Peter Steinberger
2026-01-10 03:01:04 +01:00
parent 4075895c4c
commit f28a4a34ad
15 changed files with 345 additions and 178 deletions

View File

@@ -1,18 +1,10 @@
import { getFileExtension } from "../media/mime.js";
import { isVoiceCompatibleAudio } from "../media/audio.js";
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 = getFileExtension(fileName);
if (!ext) return false;
return ext === ".ogg" || ext === ".opus" || ext === ".oga";
return isVoiceCompatibleAudio(opts);
}
export function resolveTelegramVoiceDecision(opts: {