mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-14 01:41:24 -06:00
v 1.7.4
This commit is contained in:
parent
14c210c771
commit
95907b3cea
@ -1,4 +1,4 @@
|
|||||||
# 1.7.4 (develop)
|
# 1.7.4 (2024-04-28 09:46)
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
* Adjusts in proxy on fetchAgent
|
* Adjusts in proxy on fetchAgent
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
FROM node:20.7.0-alpine AS builder
|
FROM node:20.7.0-alpine AS builder
|
||||||
|
|
||||||
LABEL version="1.7.3" description="Api to control whatsapp features through http requests."
|
LABEL version="1.7.4" description="Api to control whatsapp features through http requests."
|
||||||
LABEL maintainer="Davidson Gomes" git="https://github.com/DavidsonGomes"
|
LABEL maintainer="Davidson Gomes" git="https://github.com/DavidsonGomes"
|
||||||
LABEL contact="contato@agenciadgcode.com"
|
LABEL contact="contato@agenciadgcode.com"
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "evolution-api",
|
"name": "evolution-api",
|
||||||
"version": "1.7.3",
|
"version": "1.7.4",
|
||||||
"description": "Rest api for communication with WhatsApp",
|
"description": "Rest api for communication with WhatsApp",
|
||||||
"main": "./dist/src/main.js",
|
"main": "./dist/src/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -40,7 +40,7 @@ import makeWASocket, {
|
|||||||
import { Label } from 'baileys/lib/Types/Label';
|
import { Label } from 'baileys/lib/Types/Label';
|
||||||
import { LabelAssociation } from 'baileys/lib/Types/LabelAssociation';
|
import { LabelAssociation } from 'baileys/lib/Types/LabelAssociation';
|
||||||
import { exec } from 'child_process';
|
import { exec } from 'child_process';
|
||||||
import { arrayUnique, isBase64, isURL } from 'class-validator';
|
import { isBase64, isURL } from 'class-validator';
|
||||||
import EventEmitter2 from 'eventemitter2';
|
import EventEmitter2 from 'eventemitter2';
|
||||||
// import ffmpeg from 'fluent-ffmpeg';
|
// import ffmpeg from 'fluent-ffmpeg';
|
||||||
import fs, { existsSync, readFileSync } from 'fs';
|
import fs, { existsSync, readFileSync } from 'fs';
|
||||||
@ -97,7 +97,6 @@ import {
|
|||||||
MediaMessage,
|
MediaMessage,
|
||||||
Options,
|
Options,
|
||||||
SendAudioDto,
|
SendAudioDto,
|
||||||
SendButtonDto,
|
|
||||||
SendContactDto,
|
SendContactDto,
|
||||||
SendListDto,
|
SendListDto,
|
||||||
SendLocationDto,
|
SendLocationDto,
|
||||||
@ -2207,15 +2206,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
|
|
||||||
mimetype = response.headers['content-type'];
|
mimetype = response.headers['content-type'];
|
||||||
}
|
}
|
||||||
// if (isURL(mediaMessage.media)) {
|
|
||||||
// const response = await axios.get(mediaMessage.media, { responseType: 'arraybuffer' });
|
|
||||||
|
|
||||||
// mimetype = response.headers['content-type'];
|
|
||||||
// console.log('mediaMessage.mimetype2', mimetype);
|
|
||||||
// } else {
|
|
||||||
// mimetype = getMIMEType(mediaMessage.fileName);
|
|
||||||
// console.log('mediaMessage.mimetype3', mimetype);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logger.verbose('Mimetype: ' + mimetype);
|
this.logger.verbose('Mimetype: ' + mimetype);
|
||||||
@ -2330,82 +2320,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
return await this.sendMessageWithTyping(data.number, { ...generate.message }, data?.options, isChatwoot);
|
return await this.sendMessageWithTyping(data.number, { ...generate.message }, data?.options, isChatwoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
// public async processAudio(audio: string, number: string) {
|
|
||||||
// this.logger.verbose('Processing audio');
|
|
||||||
// let tempAudioPath: string;
|
|
||||||
// let outputAudio: string;
|
|
||||||
|
|
||||||
// number = number.replace(/\D/g, '');
|
|
||||||
// const hash = `${number}-${new Date().getTime()}`;
|
|
||||||
// this.logger.verbose('Hash to audio name: ' + hash);
|
|
||||||
|
|
||||||
// if (isURL(audio)) {
|
|
||||||
// this.logger.verbose('Audio is url');
|
|
||||||
|
|
||||||
// outputAudio = `${join(this.storePath, 'temp', `${hash}.ogg`)}`;
|
|
||||||
// tempAudioPath = `${join(this.storePath, 'temp', `temp-${hash}.mp3`)}`;
|
|
||||||
|
|
||||||
// this.logger.verbose('Output audio path: ' + outputAudio);
|
|
||||||
// this.logger.verbose('Temp audio path: ' + tempAudioPath);
|
|
||||||
|
|
||||||
// const timestamp = new Date().getTime();
|
|
||||||
// const url = `${audio}?timestamp=${timestamp}`;
|
|
||||||
|
|
||||||
// this.logger.verbose('Including timestamp in url: ' + url);
|
|
||||||
|
|
||||||
// let config: any = {
|
|
||||||
// responseType: 'arraybuffer',
|
|
||||||
// };
|
|
||||||
|
|
||||||
// if (this.localProxy.enabled) {
|
|
||||||
// config = {
|
|
||||||
// ...config,
|
|
||||||
// httpsAgent: makeProxyAgent(this.localProxy.proxy),
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
|
|
||||||
// const response = await axios.get(url, config);
|
|
||||||
// this.logger.verbose('Getting audio from url');
|
|
||||||
|
|
||||||
// fs.writeFileSync(tempAudioPath, response.data);
|
|
||||||
// } else {
|
|
||||||
// this.logger.verbose('Audio is base64');
|
|
||||||
|
|
||||||
// outputAudio = `${join(this.storePath, 'temp', `${hash}.ogg`)}`;
|
|
||||||
// tempAudioPath = `${join(this.storePath, 'temp', `temp-${hash}.mp3`)}`;
|
|
||||||
|
|
||||||
// this.logger.verbose('Output audio path: ' + outputAudio);
|
|
||||||
// this.logger.verbose('Temp audio path: ' + tempAudioPath);
|
|
||||||
|
|
||||||
// const audioBuffer = Buffer.from(audio, 'base64');
|
|
||||||
// fs.writeFileSync(tempAudioPath, audioBuffer);
|
|
||||||
// this.logger.verbose('Temp audio created');
|
|
||||||
// }
|
|
||||||
|
|
||||||
// this.logger.verbose('Converting audio to mp4');
|
|
||||||
// return new Promise((resolve, reject) => {
|
|
||||||
// // This fix was suggested by @PurpShell
|
|
||||||
// ffmpeg.setFfmpegPath(ffmpegPath.path);
|
|
||||||
|
|
||||||
// ffmpeg()
|
|
||||||
// .input(tempAudioPath)
|
|
||||||
// .outputFormat('ogg')
|
|
||||||
// .noVideo()
|
|
||||||
// .audioCodec('libopus')
|
|
||||||
// .save(outputAudio)
|
|
||||||
// .on('error', function (error) {
|
|
||||||
// console.log('error', error);
|
|
||||||
// fs.unlinkSync(tempAudioPath);
|
|
||||||
// if (error) reject(error);
|
|
||||||
// })
|
|
||||||
// .on('end', async function () {
|
|
||||||
// fs.unlinkSync(tempAudioPath);
|
|
||||||
// resolve(outputAudio);
|
|
||||||
// })
|
|
||||||
// .run();
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
public async processAudio(audio: string, number: string) {
|
public async processAudio(audio: string, number: string) {
|
||||||
this.logger.verbose('Processing audio');
|
this.logger.verbose('Processing audio');
|
||||||
let tempAudioPath: string;
|
let tempAudioPath: string;
|
||||||
@ -2506,50 +2420,8 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async buttonMessage(data: SendButtonDto) {
|
public async buttonMessage() {
|
||||||
this.logger.verbose('Sending button message');
|
throw new BadRequestException('Method not available on WhatsApp Baileys');
|
||||||
const embeddedMedia: any = {};
|
|
||||||
let mediatype = 'TEXT';
|
|
||||||
|
|
||||||
if (data.buttonMessage?.mediaMessage) {
|
|
||||||
mediatype = data.buttonMessage.mediaMessage?.mediatype.toUpperCase() ?? 'TEXT';
|
|
||||||
embeddedMedia.mediaKey = mediatype.toLowerCase() + 'Message';
|
|
||||||
const generate = await this.prepareMediaMessage(data.buttonMessage.mediaMessage);
|
|
||||||
embeddedMedia.message = generate.message[embeddedMedia.mediaKey];
|
|
||||||
embeddedMedia.contentText = `*${data.buttonMessage.title}*\n\n${data.buttonMessage.description}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
const btnItems = {
|
|
||||||
text: data.buttonMessage.buttons.map((btn) => btn.buttonText),
|
|
||||||
ids: data.buttonMessage.buttons.map((btn) => btn.buttonId),
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!arrayUnique(btnItems.text) || !arrayUnique(btnItems.ids)) {
|
|
||||||
throw new BadRequestException('Button texts cannot be repeated', 'Button IDs cannot be repeated.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return await this.sendMessageWithTyping(
|
|
||||||
data.number,
|
|
||||||
{
|
|
||||||
buttonsMessage: {
|
|
||||||
text: !embeddedMedia?.mediaKey ? data.buttonMessage.title : undefined,
|
|
||||||
contentText: embeddedMedia?.contentText ?? data.buttonMessage.description,
|
|
||||||
footerText: data.buttonMessage?.footerText,
|
|
||||||
buttons: data.buttonMessage.buttons.map((button) => {
|
|
||||||
return {
|
|
||||||
buttonText: {
|
|
||||||
displayText: button.buttonText,
|
|
||||||
},
|
|
||||||
buttonId: button.buttonId,
|
|
||||||
type: 1,
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
headerType: proto.Message.ButtonsMessage.HeaderType[mediatype],
|
|
||||||
[embeddedMedia?.mediaKey]: embeddedMedia?.message,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
data?.options,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async locationMessage(data: SendLocationDto) {
|
public async locationMessage(data: SendLocationDto) {
|
||||||
|
@ -25,7 +25,7 @@ info:
|
|||||||
</font>
|
</font>
|
||||||
|
|
||||||
[](https://god.gw.postman.com/run-collection/26869335-5546d063-156b-4529-915f-909dd628c090?action=collection%2Ffork&source=rip_markdown&collection-url=entityId%3D26869335-5546d063-156b-4529-915f-909dd628c090%26entityType%3Dcollection%26workspaceId%3D339a4ee7-378b-45c9-b5b8-fd2c0a9c2442)
|
[](https://god.gw.postman.com/run-collection/26869335-5546d063-156b-4529-915f-909dd628c090?action=collection%2Ffork&source=rip_markdown&collection-url=entityId%3D26869335-5546d063-156b-4529-915f-909dd628c090%26entityType%3Dcollection%26workspaceId%3D339a4ee7-378b-45c9-b5b8-fd2c0a9c2442)
|
||||||
version: 1.7.3
|
version: 1.7.4
|
||||||
contact:
|
contact:
|
||||||
name: DavidsonGomes
|
name: DavidsonGomes
|
||||||
email: contato@agenciadgcode.com
|
email: contato@agenciadgcode.com
|
||||||
|
Loading…
Reference in New Issue
Block a user