Skip to content

Commit 36ee4fe

Browse files
author
Kiro
committed
fix(gateway): pass doc.mime_type to download_telegram_document instead of hardcoding text/plain
- Add mime_type parameter to download_telegram_document() - Pass doc.mime_type from Telegram API at call site - Remove #[allow(dead_code)] from TelegramDocument.mime_type (now used)
1 parent b20ed30 commit 36ee4fe

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

gateway/src/adapters/telegram.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ struct TelegramPhoto {
4949
struct TelegramDocument {
5050
file_id: String,
5151
file_name: Option<String>,
52-
#[allow(dead_code)]
5352
mime_type: Option<String>,
5453
}
5554

@@ -139,8 +138,9 @@ pub async fn webhook(
139138
}
140139
} else if let Some(doc) = msg.document {
141140
let file_name = doc.file_name.unwrap_or_else(|| "unknown.txt".to_string());
141+
let mime = doc.mime_type.unwrap_or_else(|| "text/plain".to_string());
142142
if let Some(att) =
143-
download_telegram_document(client, token, &doc.file_id, &file_name).await
143+
download_telegram_document(client, token, &doc.file_id, &file_name, &mime).await
144144
{
145145
attachments.push(att);
146146
}
@@ -437,6 +437,7 @@ async fn download_telegram_document(
437437
bot_token: &str,
438438
file_id: &str,
439439
file_name: &str,
440+
mime_type: &str,
440441
) -> Option<Attachment> {
441442
// Only download text-like files
442443
let ext = file_name.rsplit('.').next().unwrap_or("").to_lowercase();
@@ -499,7 +500,7 @@ async fn download_telegram_document(
499500
Some(Attachment {
500501
attachment_type: "text_file".into(),
501502
filename: file_name.to_string(),
502-
mime_type: "text/plain".into(),
503+
mime_type: mime_type.into(),
503504
data,
504505
size: bytes.len() as u64,
505506
})

0 commit comments

Comments
 (0)