sddssddssd
This commit is contained in:
parent
fd2062fb04
commit
38d3d99550
17
index.js
17
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',
|
||||
},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user