fix: make forwardToStorage fully dynamic based on fileType

- Replace forceDocument boolean with fileType string in forwardToStorage
- Dynamically call matching sendPhoto, sendAudio, sendVideo, sendVoice, sendAnimation, sendSticker, or sendDocument Telegraf API method
- Correctly extract uploaded file details based on what Telegram returned
- Fixes IMAGE_PROCESS_FAILED 500 error when uploading ogg audio, video, sticker, or voice notes via HTTP
- Update upload.ts, bot.ts, and test suites to match the new dynamic signature

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
MythEclipse
2026-05-18 19:52:46 +07:00
co-authored by Claude Opus 4.7
parent bf6d5f04c4
commit 525348b1f3
5 changed files with 50 additions and 23 deletions
+3 -3
View File
@@ -132,7 +132,7 @@ describe('Telegram Bot Handler', () => {
};
await fileHandler(ctx);
expect(mockForwardToStorage).toHaveBeenCalledWith('doc_123', 'cv.pdf');
expect(mockForwardToStorage).toHaveBeenCalledWith('doc_123', 'cv.pdf', 'document');
expect(mockInsert).toHaveBeenCalled();
expect(replyMock).toHaveBeenCalledWith(
expect.stringContaining('File berhasil diupload'),
@@ -233,7 +233,7 @@ describe('Telegram Bot Handler', () => {
};
await fileHandler(ctx);
expect(mockForwardToStorage).toHaveBeenCalledWith('sticker_123', 'file');
expect(mockForwardToStorage).toHaveBeenCalledWith('sticker_123', 'file', 'sticker');
expect(mockInsert).toHaveBeenCalled();
expect(replyMock).toHaveBeenCalledWith(
expect.stringContaining('File berhasil diupload'),
@@ -263,7 +263,7 @@ describe('Telegram Bot Handler', () => {
};
await fileHandler(ctx);
expect(mockForwardToStorage).toHaveBeenCalledWith('video_note_123', 'file');
expect(mockForwardToStorage).toHaveBeenCalledWith('video_note_123', 'file', 'video_note');
expect(mockInsert).toHaveBeenCalled();
expect(replyMock).toHaveBeenCalledWith(
expect.stringContaining('File berhasil diupload'),