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