mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-16 04:02:54 -06:00
Fixed cash when sending stickers via url
This commit is contained in:
parent
77f98c2438
commit
8cb431ad40
@ -5,6 +5,7 @@
|
|||||||
* Added timestamp internally in urls to avoid caching
|
* Added timestamp internally in urls to avoid caching
|
||||||
* Correction in decryption of poll votes
|
* 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
|
* 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)
|
# 1.1.2 (2023-06-28 13:43)
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ services:
|
|||||||
- DATABASE_SAVE_MESSAGE_UPDATE=true
|
- DATABASE_SAVE_MESSAGE_UPDATE=true
|
||||||
- DATABASE_SAVE_DATA_CONTACTS=true
|
- DATABASE_SAVE_DATA_CONTACTS=true
|
||||||
- DATABASE_SAVE_DATA_CHATS=true
|
- DATABASE_SAVE_DATA_CHATS=true
|
||||||
- REDIS_ENABLED=false
|
- REDIS_ENABLED=true
|
||||||
- REDIS_URI=redis://redis:6379/1
|
- REDIS_URI=redis://redis:6379/1
|
||||||
- REDIS_PREFIX_KEY=evolution
|
- REDIS_PREFIX_KEY=evolution
|
||||||
# Webhook Settings
|
# Webhook Settings
|
||||||
|
@ -1167,7 +1167,10 @@ export class WAStartupService {
|
|||||||
imagePath = `${join(process.cwd(), 'temp', 'temp-sticker.png')}`;
|
imagePath = `${join(process.cwd(), 'temp', 'temp-sticker.png')}`;
|
||||||
await sharp(imageBuffer).toFile(imagePath);
|
await sharp(imageBuffer).toFile(imagePath);
|
||||||
} else {
|
} 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');
|
const imageBuffer = Buffer.from(response.data, 'binary');
|
||||||
imagePath = `${join(process.cwd(), 'temp', 'temp-sticker.png')}`;
|
imagePath = `${join(process.cwd(), 'temp', 'temp-sticker.png')}`;
|
||||||
await sharp(imageBuffer).toFile(imagePath);
|
await sharp(imageBuffer).toFile(imagePath);
|
||||||
@ -1175,6 +1178,8 @@ export class WAStartupService {
|
|||||||
|
|
||||||
await sharp(imagePath).webp().toFile(outputPath);
|
await sharp(imagePath).webp().toFile(outputPath);
|
||||||
|
|
||||||
|
fs.unlinkSync(imagePath);
|
||||||
|
|
||||||
return outputPath;
|
return outputPath;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Erro ao converter a imagem para WebP:', error);
|
console.error('Erro ao converter a imagem para WebP:', error);
|
||||||
@ -1183,13 +1188,17 @@ export class WAStartupService {
|
|||||||
|
|
||||||
public async mediaSticker(data: SendStickerDto) {
|
public async mediaSticker(data: SendStickerDto) {
|
||||||
const convert = await this.convertToWebP(data.stickerMessage.image);
|
const convert = await this.convertToWebP(data.stickerMessage.image);
|
||||||
return await this.sendMessageWithTyping(
|
const result = await this.sendMessageWithTyping(
|
||||||
data.number,
|
data.number,
|
||||||
{
|
{
|
||||||
sticker: { url: convert },
|
sticker: { url: convert },
|
||||||
},
|
},
|
||||||
data?.options,
|
data?.options,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
fs.unlinkSync(convert);
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async mediaMessage(data: SendMediaDto) {
|
public async mediaMessage(data: SendMediaDto) {
|
||||||
@ -1225,7 +1234,6 @@ export class WAStartupService {
|
|||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
exec(
|
exec(
|
||||||
// `${ffmpegPath.path} -i ${tempAudioPath} -c:a libopus ${outputAudio} -y`,
|
|
||||||
`${ffmpegPath.path} -i ${tempAudioPath} -vn -ab 128k -ar 44100 -f ipod ${outputAudio} -y`,
|
`${ffmpegPath.path} -i ${tempAudioPath} -vn -ab 128k -ar 44100 -f ipod ${outputAudio} -y`,
|
||||||
(error, _stdout, _stderr) => {
|
(error, _stdout, _stderr) => {
|
||||||
fs.unlinkSync(tempAudioPath);
|
fs.unlinkSync(tempAudioPath);
|
||||||
@ -1245,7 +1253,6 @@ export class WAStartupService {
|
|||||||
{
|
{
|
||||||
audio: Buffer.from(audio, 'base64'),
|
audio: Buffer.from(audio, 'base64'),
|
||||||
ptt: true,
|
ptt: true,
|
||||||
// mimetype: 'audio/ogg; codecs=opus',
|
|
||||||
mimetype: 'audio/mp4',
|
mimetype: 'audio/mp4',
|
||||||
},
|
},
|
||||||
{ presence: 'recording', delay: data?.options?.delay },
|
{ 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 |
Loading…
Reference in New Issue
Block a user