@@ -2,6 +2,7 @@ import { TelegramIcon } from '@/components/icons'
22import type { BlockConfig } from '@/blocks/types'
33import { AuthMode } from '@/blocks/types'
44import { normalizeFileInput } from '@/blocks/utils'
5+ import { normalizeTelegramMediaParam } from '@/tools/telegram/media'
56import type { TelegramResponse } from '@/tools/telegram/types'
67import { getTrigger } from '@/triggers'
78
@@ -269,55 +270,54 @@ export const TelegramBlock: BlockConfig<TelegramResponse> = {
269270 messageId : params . messageId ,
270271 }
271272 case 'telegram_send_photo' : {
272- // photo is the canonical param for both basic (photoFile) and advanced modes
273- const photoSource = normalizeFileInput ( params . photo , {
274- single : true ,
273+ // photo supports both public URLs/file_ids and UserFile objects.
274+ // Backwards-compatible aliases (e.g., `withPhoto`) are supported for older saved workflows.
275+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
276+ const rawPhoto = params . photo ?? ( params as any ) . withPhoto ?? ( params as any ) . with_photo
277+ const photoSource = normalizeTelegramMediaParam ( rawPhoto , {
278+ label : 'Photo' ,
279+ errorMessage : 'Photo is required.' ,
275280 } )
276- if ( ! photoSource ) {
277- throw new Error ( 'Photo is required.' )
278- }
279281 return {
280282 ...commonParams ,
281283 photo : photoSource ,
282284 caption : params . caption ,
283285 }
284286 }
285287 case 'telegram_send_video' : {
286- // video is the canonical param for both basic (videoFile) and advanced modes
287- const videoSource = normalizeFileInput ( params . video , {
288- single : true ,
288+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
289+ const rawVideo = params . video ?? ( params as any ) . withVideo ?? ( params as any ) . with_video
290+ const videoSource = normalizeTelegramMediaParam ( rawVideo , {
291+ label : 'Video' ,
292+ errorMessage : 'Video is required.' ,
289293 } )
290- if ( ! videoSource ) {
291- throw new Error ( 'Video is required.' )
292- }
293294 return {
294295 ...commonParams ,
295296 video : videoSource ,
296297 caption : params . caption ,
297298 }
298299 }
299300 case 'telegram_send_audio' : {
300- // audio is the canonical param for both basic (audioFile) and advanced modes
301- const audioSource = normalizeFileInput ( params . audio , {
302- single : true ,
301+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
302+ const rawAudio = params . audio ?? ( params as any ) . withAudio ?? ( params as any ) . with_audio
303+ const audioSource = normalizeTelegramMediaParam ( rawAudio , {
304+ label : 'Audio' ,
305+ errorMessage : 'Audio is required.' ,
303306 } )
304- if ( ! audioSource ) {
305- throw new Error ( 'Audio is required.' )
306- }
307307 return {
308308 ...commonParams ,
309309 audio : audioSource ,
310310 caption : params . caption ,
311311 }
312312 }
313313 case 'telegram_send_animation' : {
314- // animation is the canonical param for both basic (animationFile) and advanced modes
315- const animationSource = normalizeFileInput ( params . animation , {
316- single : true ,
314+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
315+ const rawAnimation =
316+ params . animation ?? ( params as any ) . withAnimation ?? ( params as any ) . with_animation
317+ const animationSource = normalizeTelegramMediaParam ( rawAnimation , {
318+ label : 'Animation' ,
319+ errorMessage : 'Animation is required.' ,
317320 } )
318- if ( ! animationSource ) {
319- throw new Error ( 'Animation is required.' )
320- }
321321 return {
322322 ...commonParams ,
323323 animation : animationSource ,
0 commit comments