diff --git a/index.js b/index.js index aea965b..e49d452 100644 --- a/index.js +++ b/index.js @@ -125,14 +125,19 @@ app.post('/sendInteractiveImage', async (req, res) => { if (!sock || !isConnected) return res.status(400).json({ error: 'Non connecté' }); try { + const { prepareWAMessageMedia } = require('@fizzxydev/baileys-pro'); const imagePath = path.join(__dirname, 'public', 'logo-merlo-cs-FR.jpg'); const imageBuffer = fs.readFileSync(imagePath); - // Préparation du média avec upload sécurisé - const uploadedMedia = await sock.uploadMedia(imageBuffer, { - mimetype: 'image/jpeg', - filename: 'merlo-image.jpg' - }); + // Préparation du média avec la méthode officielle + const preparedImage = await prepareWAMessageMedia( + { image: imageBuffer }, + { + upload: sock.aws.uploadStream, // Méthode correcte d'upload + mediaType: 'image', + options: { contentType: 'image/jpeg' } + } + ); // Construction du message interactif const message = { @@ -140,7 +145,7 @@ app.post('/sendInteractiveImage', async (req, res) => { type: 'button', header: { type: 'IMAGE', - image: { url: uploadedMedia }, + image: preparedImage.image, // Utilisation du média préparé title: title || 'Titre par défaut', subtitle: subtitle || 'Sous-titre', },