fix(agent): send SVG attachments as files

This commit is contained in:
xp
2026-05-05 19:36:09 +08:00
parent 5745957429
commit d601b75268
2 changed files with 83 additions and 1 deletions
+7 -1
View File
@@ -285,6 +285,12 @@ func inferMediaType(filename, contentType string) string {
ct := strings.ToLower(contentType)
fn := strings.ToLower(filename)
// SVG is an image MIME type, but raster-only delivery endpoints such as
// Telegram SendPhoto reject it. Treat it as a file/document instead.
if strings.HasPrefix(ct, "image/svg") || filepath.Ext(fn) == ".svg" {
return "file"
}
if strings.HasPrefix(ct, "image/") {
return "image"
}
@@ -298,7 +304,7 @@ func inferMediaType(filename, contentType string) string {
// Fallback: infer from extension
ext := filepath.Ext(fn)
switch ext {
case ".jpg", ".jpeg", ".png", ".gif", ".webp", ".bmp", ".svg":
case ".jpg", ".jpeg", ".png", ".gif", ".webp", ".bmp":
return "image"
case ".mp3", ".wav", ".ogg", ".m4a", ".flac", ".aac", ".wma", ".opus":
return "audio"