@@ -2640,28 +2640,57 @@ export class BaileysStartupService extends ChannelStartupService {
26402640 throw new BadRequestException ( 'Text is required' ) ;
26412641 }
26422642
2643- // Forked patch (v2.3.7-lp): monta WAUrlInfo se veio linkPreviewOverride
2644- // (contorna Baileys link-preview que falha com shorteners)
2643+ // Forked patch (v2.3.7-lp): monta WAUrlInfo se veio linkPreviewOverride.
2644+ // v2.3.7.1: faz upload real da imagem via prepareWAMessageMedia pra ter
2645+ // highQualityThumbnail completo (directPath/mediaKey/...), fazendo WhatsApp
2646+ // renderizar como HERO CARD (imagem grande) em vez de thumbnail lateral.
26452647 let linkPreviewOverride : any = undefined ;
26462648 if ( data . linkPreviewOverride ) {
26472649 const ov = data . linkPreviewOverride ;
26482650 const urlMatch = text . match ( / h t t p s ? : \/ \/ \S + / i) ;
26492651 if ( urlMatch ) {
2650- linkPreviewOverride = {
2652+ const base : any = {
26512653 'matched-text' : urlMatch [ 0 ] ,
26522654 matchedText : urlMatch [ 0 ] ,
26532655 'canonical-url' : ov . canonicalUrl ?? urlMatch [ 0 ] ,
26542656 canonicalUrl : ov . canonicalUrl ?? urlMatch [ 0 ] ,
26552657 title : ov . title ,
26562658 description : ov . description ,
2657- ...( ov . thumbnailUrl && {
2658- thumbnailUrl : ov . thumbnailUrl ,
2659- 'thumbnail-url' : ov . thumbnailUrl ,
2660- } ) ,
2661- ...( ov . jpegThumbnail && {
2662- jpegThumbnail : Buffer . from ( ov . jpegThumbnail , 'base64' ) ,
2663- } ) ,
26642659 } ;
2660+
2661+ // Tenta upload pra ter hero card. Se falhar, fallback pra thumbnail simples.
2662+ const imgSource = ov . jpegThumbnail
2663+ ? Buffer . from ( ov . jpegThumbnail , 'base64' )
2664+ : ov . thumbnailUrl
2665+ ? { url : ov . thumbnailUrl }
2666+ : undefined ;
2667+
2668+ if ( imgSource ) {
2669+ try {
2670+ const { imageMessage } = await prepareWAMessageMedia ( { image : imgSource as any } , {
2671+ upload : this . client . waUploadToServer ,
2672+ mediaTypeOverride : 'thumbnail-link' as any ,
2673+ } as any ) ;
2674+ if ( imageMessage ) {
2675+ base . jpegThumbnail = imageMessage . jpegThumbnail
2676+ ? Buffer . from ( imageMessage . jpegThumbnail as any )
2677+ : undefined ;
2678+ base . highQualityThumbnail = imageMessage ;
2679+ }
2680+ } catch ( err ) {
2681+ this . logger . warn (
2682+ `linkPreviewOverride: upload failed, falling back to simple thumbnail: ${ err ?. message ?? err } ` ,
2683+ ) ;
2684+ if ( ov . jpegThumbnail ) {
2685+ base . jpegThumbnail = Buffer . from ( ov . jpegThumbnail , 'base64' ) ;
2686+ } else if ( ov . thumbnailUrl ) {
2687+ base . thumbnailUrl = ov . thumbnailUrl ;
2688+ base [ 'thumbnail-url' ] = ov . thumbnailUrl ;
2689+ }
2690+ }
2691+ }
2692+
2693+ linkPreviewOverride = base ;
26652694 }
26662695 }
26672696
0 commit comments