mirror of
https://github.com/cheveguerra/ws-api-node.git
synced 2026-04-17 19:36:23 +00:00
fix: validacion de url de imagen valida.
This commit is contained in:
@@ -50,11 +50,10 @@ router.post('/sendimage/', async (req,res) => {
|
||||
if (!fs.existsSync('./temp')) {
|
||||
await fs.mkdirSync('./temp');
|
||||
}
|
||||
|
||||
var path = './temp/' + image.split("/").slice(-1)[0]
|
||||
if (fs.existsSync(path)){
|
||||
mediadownloader(image, path, () => {
|
||||
let media = MessageMedia.fromFilePath(path);
|
||||
|
||||
client.sendMessage(`${phone}@c.us`, media, { caption: caption || '' }).then((response) => {
|
||||
if (response.id.fromMe) {
|
||||
res.send({ status: 'success', message: `MediaMessage successfully sent to ${phone}` })
|
||||
@@ -62,6 +61,10 @@ router.post('/sendimage/', async (req,res) => {
|
||||
}
|
||||
});
|
||||
})
|
||||
} else {
|
||||
console.log("La imagen no existe o no se pudo descargar.")
|
||||
res.send({ status:'error', message: 'Invalid URL/Base64 Encoded Media' })
|
||||
}
|
||||
} else {
|
||||
res.send({ status:'error', message: 'Invalid URL/Base64 Encoded Media' })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user