Fixed cash when sending stickers via url

This commit is contained in:
Davidson Gomes 2023-07-02 21:31:10 -03:00
parent 77f98c2438
commit 8cb431ad40
5 changed files with 13 additions and 5 deletions

View File

@ -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)

View File

@ -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

View File

@ -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 },

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.4 KiB