Skip to content

Commit 95907b3

Browse files
committed
v 1.7.4
1 parent 14c210c commit 95907b3

File tree

5 files changed

+7
-135
lines changed

5 files changed

+7
-135
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 1.7.4 (develop)
1+
# 1.7.4 (2024-04-28 09:46)
22

33
### Fixed
44
* Adjusts in proxy on fetchAgent

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM node:20.7.0-alpine AS builder
22

3-
LABEL version="1.7.3" description="Api to control whatsapp features through http requests."
3+
LABEL version="1.7.4" description="Api to control whatsapp features through http requests."
44
LABEL maintainer="Davidson Gomes" git="https://github.com/DavidsonGomes"
55
LABEL contact="contato@agenciadgcode.com"
66

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "evolution-api",
3-
"version": "1.7.3",
3+
"version": "1.7.4",
44
"description": "Rest api for communication with WhatsApp",
55
"main": "./dist/src/main.js",
66
"scripts": {

src/api/services/channels/whatsapp.baileys.service.ts

Lines changed: 3 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import makeWASocket, {
4040
import { Label } from 'baileys/lib/Types/Label';
4141
import { LabelAssociation } from 'baileys/lib/Types/LabelAssociation';
4242
import { exec } from 'child_process';
43-
import { arrayUnique, isBase64, isURL } from 'class-validator';
43+
import { isBase64, isURL } from 'class-validator';
4444
import EventEmitter2 from 'eventemitter2';
4545
// import ffmpeg from 'fluent-ffmpeg';
4646
import fs, { existsSync, readFileSync } from 'fs';
@@ -97,7 +97,6 @@ import {
9797
MediaMessage,
9898
Options,
9999
SendAudioDto,
100-
SendButtonDto,
101100
SendContactDto,
102101
SendListDto,
103102
SendLocationDto,
@@ -2207,15 +2206,6 @@ export class BaileysStartupService extends ChannelStartupService {
22072206

22082207
mimetype = response.headers['content-type'];
22092208
}
2210-
// if (isURL(mediaMessage.media)) {
2211-
// const response = await axios.get(mediaMessage.media, { responseType: 'arraybuffer' });
2212-
2213-
// mimetype = response.headers['content-type'];
2214-
// console.log('mediaMessage.mimetype2', mimetype);
2215-
// } else {
2216-
// mimetype = getMIMEType(mediaMessage.fileName);
2217-
// console.log('mediaMessage.mimetype3', mimetype);
2218-
// }
22192209
}
22202210

22212211
this.logger.verbose('Mimetype: ' + mimetype);
@@ -2330,82 +2320,6 @@ export class BaileysStartupService extends ChannelStartupService {
23302320
return await this.sendMessageWithTyping(data.number, { ...generate.message }, data?.options, isChatwoot);
23312321
}
23322322

2333-
// public async processAudio(audio: string, number: string) {
2334-
// this.logger.verbose('Processing audio');
2335-
// let tempAudioPath: string;
2336-
// let outputAudio: string;
2337-
2338-
// number = number.replace(/\D/g, '');
2339-
// const hash = `${number}-${new Date().getTime()}`;
2340-
// this.logger.verbose('Hash to audio name: ' + hash);
2341-
2342-
// if (isURL(audio)) {
2343-
// this.logger.verbose('Audio is url');
2344-
2345-
// outputAudio = `${join(this.storePath, 'temp', `${hash}.ogg`)}`;
2346-
// tempAudioPath = `${join(this.storePath, 'temp', `temp-${hash}.mp3`)}`;
2347-
2348-
// this.logger.verbose('Output audio path: ' + outputAudio);
2349-
// this.logger.verbose('Temp audio path: ' + tempAudioPath);
2350-
2351-
// const timestamp = new Date().getTime();
2352-
// const url = `${audio}?timestamp=${timestamp}`;
2353-
2354-
// this.logger.verbose('Including timestamp in url: ' + url);
2355-
2356-
// let config: any = {
2357-
// responseType: 'arraybuffer',
2358-
// };
2359-
2360-
// if (this.localProxy.enabled) {
2361-
// config = {
2362-
// ...config,
2363-
// httpsAgent: makeProxyAgent(this.localProxy.proxy),
2364-
// };
2365-
// }
2366-
2367-
// const response = await axios.get(url, config);
2368-
// this.logger.verbose('Getting audio from url');
2369-
2370-
// fs.writeFileSync(tempAudioPath, response.data);
2371-
// } else {
2372-
// this.logger.verbose('Audio is base64');
2373-
2374-
// outputAudio = `${join(this.storePath, 'temp', `${hash}.ogg`)}`;
2375-
// tempAudioPath = `${join(this.storePath, 'temp', `temp-${hash}.mp3`)}`;
2376-
2377-
// this.logger.verbose('Output audio path: ' + outputAudio);
2378-
// this.logger.verbose('Temp audio path: ' + tempAudioPath);
2379-
2380-
// const audioBuffer = Buffer.from(audio, 'base64');
2381-
// fs.writeFileSync(tempAudioPath, audioBuffer);
2382-
// this.logger.verbose('Temp audio created');
2383-
// }
2384-
2385-
// this.logger.verbose('Converting audio to mp4');
2386-
// return new Promise((resolve, reject) => {
2387-
// // This fix was suggested by @PurpShell
2388-
// ffmpeg.setFfmpegPath(ffmpegPath.path);
2389-
2390-
// ffmpeg()
2391-
// .input(tempAudioPath)
2392-
// .outputFormat('ogg')
2393-
// .noVideo()
2394-
// .audioCodec('libopus')
2395-
// .save(outputAudio)
2396-
// .on('error', function (error) {
2397-
// console.log('error', error);
2398-
// fs.unlinkSync(tempAudioPath);
2399-
// if (error) reject(error);
2400-
// })
2401-
// .on('end', async function () {
2402-
// fs.unlinkSync(tempAudioPath);
2403-
// resolve(outputAudio);
2404-
// })
2405-
// .run();
2406-
// });
2407-
// }
2408-
24092323
public async processAudio(audio: string, number: string) {
24102324
this.logger.verbose('Processing audio');
24112325
let tempAudioPath: string;
@@ -2506,50 +2420,8 @@ export class BaileysStartupService extends ChannelStartupService {
25062420
);
25072421
}
25082422

2509-
public async buttonMessage(data: SendButtonDto) {
2510-
this.logger.verbose('Sending button message');
2511-
const embeddedMedia: any = {};
2512-
let mediatype = 'TEXT';
2513-
2514-
if (data.buttonMessage?.mediaMessage) {
2515-
mediatype = data.buttonMessage.mediaMessage?.mediatype.toUpperCase() ?? 'TEXT';
2516-
embeddedMedia.mediaKey = mediatype.toLowerCase() + 'Message';
2517-
const generate = await this.prepareMediaMessage(data.buttonMessage.mediaMessage);
2518-
embeddedMedia.message = generate.message[embeddedMedia.mediaKey];
2519-
embeddedMedia.contentText = `*${data.buttonMessage.title}*\n\n${data.buttonMessage.description}`;
2520-
}
2521-
2522-
const btnItems = {
2523-
text: data.buttonMessage.buttons.map((btn) => btn.buttonText),
2524-
ids: data.buttonMessage.buttons.map((btn) => btn.buttonId),
2525-
};
2526-
2527-
if (!arrayUnique(btnItems.text) || !arrayUnique(btnItems.ids)) {
2528-
throw new BadRequestException('Button texts cannot be repeated', 'Button IDs cannot be repeated.');
2529-
}
2530-
2531-
return await this.sendMessageWithTyping(
2532-
data.number,
2533-
{
2534-
buttonsMessage: {
2535-
text: !embeddedMedia?.mediaKey ? data.buttonMessage.title : undefined,
2536-
contentText: embeddedMedia?.contentText ?? data.buttonMessage.description,
2537-
footerText: data.buttonMessage?.footerText,
2538-
buttons: data.buttonMessage.buttons.map((button) => {
2539-
return {
2540-
buttonText: {
2541-
displayText: button.buttonText,
2542-
},
2543-
buttonId: button.buttonId,
2544-
type: 1,
2545-
};
2546-
}),
2547-
headerType: proto.Message.ButtonsMessage.HeaderType[mediatype],
2548-
[embeddedMedia?.mediaKey]: embeddedMedia?.message,
2549-
},
2550-
},
2551-
data?.options,
2552-
);
2423+
public async buttonMessage() {
2424+
throw new BadRequestException('Method not available on WhatsApp Baileys');
25532425
}
25542426

25552427
public async locationMessage(data: SendLocationDto) {

src/docs/swagger.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ info:
2525
</font>
2626
2727
[![Run in Postman](https://run.pstmn.io/button.svg)](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)
28-
version: 1.7.3
28+
version: 1.7.4
2929
contact:
3030
name: DavidsonGomes
3131
email: contato@agenciadgcode.com

0 commit comments

Comments
 (0)