diff --git a/CHANGELOG.md b/CHANGELOG.md index 397a3ada..1eb001bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * Added timestamp internally in urls to avoid caching * Correction in decryption of poll votes * Change in the way the api sent and saved the sent messages, now it goes in the messages.upsert event +* Fixed cash when sending stickers via url # 1.1.2 (2023-06-28 13:43) diff --git a/docker-compose.yaml b/docker-compose.yaml index 8686bd2e..8cd8a901 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -39,7 +39,7 @@ services: - DATABASE_SAVE_MESSAGE_UPDATE=true - DATABASE_SAVE_DATA_CONTACTS=true - DATABASE_SAVE_DATA_CHATS=true - - REDIS_ENABLED=false + - REDIS_ENABLED=true - REDIS_URI=redis://redis:6379/1 - REDIS_PREFIX_KEY=evolution # Webhook Settings diff --git a/src/whatsapp/services/whatsapp.service.ts b/src/whatsapp/services/whatsapp.service.ts index ca38cbeb..fb63057c 100644 --- a/src/whatsapp/services/whatsapp.service.ts +++ b/src/whatsapp/services/whatsapp.service.ts @@ -1167,7 +1167,10 @@ export class WAStartupService { imagePath = `${join(process.cwd(), 'temp', 'temp-sticker.png')}`; await sharp(imageBuffer).toFile(imagePath); } else { - const response = await axios.get(image, { responseType: 'arraybuffer' }); + const timestamp = new Date().getTime(); + const url = `${image}?timestamp=${timestamp}`; + + const response = await axios.get(url, { responseType: 'arraybuffer' }); const imageBuffer = Buffer.from(response.data, 'binary'); imagePath = `${join(process.cwd(), 'temp', 'temp-sticker.png')}`; await sharp(imageBuffer).toFile(imagePath); @@ -1175,6 +1178,8 @@ export class WAStartupService { await sharp(imagePath).webp().toFile(outputPath); + fs.unlinkSync(imagePath); + return outputPath; } catch (error) { console.error('Erro ao converter a imagem para WebP:', error); @@ -1183,13 +1188,17 @@ export class WAStartupService { public async mediaSticker(data: SendStickerDto) { const convert = await this.convertToWebP(data.stickerMessage.image); - return await this.sendMessageWithTyping( + const result = await this.sendMessageWithTyping( data.number, { sticker: { url: convert }, }, data?.options, ); + + fs.unlinkSync(convert); + + return result; } public async mediaMessage(data: SendMediaDto) { @@ -1225,7 +1234,6 @@ export class WAStartupService { return new Promise((resolve, reject) => { exec( - // `${ffmpegPath.path} -i ${tempAudioPath} -c:a libopus ${outputAudio} -y`, `${ffmpegPath.path} -i ${tempAudioPath} -vn -ab 128k -ar 44100 -f ipod ${outputAudio} -y`, (error, _stdout, _stderr) => { fs.unlinkSync(tempAudioPath); @@ -1245,7 +1253,6 @@ export class WAStartupService { { audio: Buffer.from(audio, 'base64'), ptt: true, - // mimetype: 'audio/ogg; codecs=opus', mimetype: 'audio/mp4', }, { presence: 'recording', delay: data?.options?.delay }, diff --git a/temp/sticker.webp b/temp/sticker.webp deleted file mode 100644 index 4ceb886e..00000000 Binary files a/temp/sticker.webp and /dev/null differ diff --git a/temp/sticker.webp_original b/temp/sticker.webp_original deleted file mode 100644 index b04e82da..00000000 Binary files a/temp/sticker.webp_original and /dev/null differ