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:
co-authored by
Claude Opus 4.7
parent
bf6d5f04c4
commit
525348b1f3
@@ -68,7 +68,7 @@ describe('Telegram API Utilities', () => {
|
||||
it('should forward photo to storage chat and return file details', async () => {
|
||||
const chunk = Buffer.from('fake photo data');
|
||||
const fileName = 'test_photo.jpg';
|
||||
const result = await forwardToStorage(chunk, fileName, false);
|
||||
const result = await forwardToStorage(chunk, fileName, 'photo');
|
||||
|
||||
expect(result).toEqual({
|
||||
telegramFileId: 'photo_id_high',
|
||||
@@ -86,7 +86,7 @@ describe('Telegram API Utilities', () => {
|
||||
const chunk = Buffer.from('fake document data');
|
||||
const fileName = 'document.pdf';
|
||||
|
||||
const result = await forwardToStorage(chunk, fileName, true);
|
||||
const result = await forwardToStorage(chunk, fileName, 'document');
|
||||
|
||||
expect(bot.telegram.sendDocument).toHaveBeenCalledWith(
|
||||
config.storageChatId,
|
||||
@@ -107,7 +107,7 @@ describe('Telegram API Utilities', () => {
|
||||
const chunk = Buffer.from('fake photo data');
|
||||
const fileName = 'test_photo.jpg';
|
||||
|
||||
await expect(forwardToStorage(chunk, fileName, false)).rejects.toThrow(
|
||||
await expect(forwardToStorage(chunk, fileName, 'photo')).rejects.toThrow(
|
||||
'Telegram send failed',
|
||||
);
|
||||
expect(errorSpy).toHaveBeenCalledWith('Failed to forward file to storage', {
|
||||
|
||||
Reference in New Issue
Block a user