Skip to content

Commit af7a5d3

Browse files
committed
Merge branch 'develop' of github.com:EvolutionAPI/evolution-api into develop
2 parents 7b1a455 + b3e213c commit af7a5d3

14 files changed

+230
-168
lines changed

CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
### Features
44

55
* Added messages.delete event
6+
* Added restart instance endpoint
7+
* Created automation for creating instances in the chatwoot bot with the command '#inbox_whatsapp:<INSTANCE_NAME>'
8+
* Change Baileys version to: 6.4.0
9+
* Send contact in chatwoot
610

711
### Fixed
812

@@ -12,7 +16,14 @@
1216
* Added validations in create instance
1317
* Removed link preview endpoint, now it's done automatically from sending conventional text
1418
* Added group membership validation before sending message to groups
15-
* Adjusts in Dockerfile
19+
* Adjusts in docker files
20+
* Adjusts in returns in endpoints chatwoot and webhook
21+
* Fixed ghost mentions in send text message
22+
* Fixed bug that saved contacts from groups came without number in chatwoot
23+
* Fixed problem to receive csat in chatwoot
24+
* Fixed require fileName for document only in base64 for send media message
25+
* Bug fix when sending mobile message change contact name to number in chatwoot
26+
* Bug fix when connecting whatsapp does not send confirmation message
1627

1728
# 1.2.2 (2023-07-15 09:36)
1829

Docker/mongodb/docker-compose.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,5 @@ volumes:
3737

3838
networks:
3939
evolution-net:
40-
name: evolution-net
4140
external: true
4241

Docker/redis/docker-compose.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,4 @@ volumes:
2525

2626
networks:
2727
evolution-net:
28-
name: evolution-net
2928
external: true

docker-compose-full.yaml

Lines changed: 0 additions & 73 deletions
This file was deleted.

docker-compose.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,5 @@ volumes:
2222

2323
networks:
2424
evolution-net:
25-
name: evolution-net
2625
external: true
2726

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
"@ffmpeg-installer/ffmpeg": "^1.1.0",
4545
"@figuro/chatwoot-sdk": "^1.1.14",
4646
"@hapi/boom": "^10.0.1",
47-
"@whiskeysockets/baileys": "github:DavidsonGomes/Baileys",
47+
"@sentry/node": "^7.59.2",
48+
"@whiskeysockets/baileys": "^6.4.0",
4849
"axios": "^1.3.5",
4950
"class-validator": "^0.13.2",
5051
"compression": "^1.7.4",

src/main.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { waMonitor } from './whatsapp/whatsapp.module';
1010
import { HttpStatus, router } from './whatsapp/routers/index.router';
1111
import 'express-async-errors';
1212
import { ServerUP } from './utils/server-up';
13+
import * as Sentry from '@sentry/node';
1314

1415
function initWA() {
1516
waMonitor.loadInstance();
@@ -19,6 +20,27 @@ function bootstrap() {
1920
const logger = new Logger('SERVER');
2021
const app = express();
2122

23+
// Sentry.init({
24+
// dsn: '',
25+
// integrations: [
26+
// // enable HTTP calls tracing
27+
// new Sentry.Integrations.Http({ tracing: true }),
28+
// // enable Express.js middleware tracing
29+
// new Sentry.Integrations.Express({ app }),
30+
// // Automatically instrument Node.js libraries and frameworks
31+
// ...Sentry.autoDiscoverNodePerformanceMonitoringIntegrations(),
32+
// ],
33+
34+
// // Set tracesSampleRate to 1.0 to capture 100%
35+
// // of transactions for performance monitoring.
36+
// // We recommend adjusting this value in production
37+
// tracesSampleRate: 1.0,
38+
// });
39+
40+
// app.use(Sentry.Handlers.requestHandler());
41+
42+
// app.use(Sentry.Handlers.tracingHandler());
43+
2244
app.use(
2345
cors({
2446
origin(requestOrigin, callback) {
@@ -43,6 +65,13 @@ function bootstrap() {
4365

4466
app.use('/', router);
4567

68+
// app.use(Sentry.Handlers.errorHandler());
69+
70+
// app.use(function onError(err, req, res, next) {
71+
// res.statusCode = 500;
72+
// res.end(res.sentry + '\n');
73+
// });
74+
4675
app.use(
4776
(err: Error, req: Request, res: Response, next: NextFunction) => {
4877
if (err) {

src/whatsapp/controllers/chatwoot.controller.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,18 @@ export class ChatwootController {
6666

6767
const urlServer = this.configService.get<HttpServer>('SERVER').URL;
6868

69+
if (Object.keys(result).length === 0) {
70+
return {
71+
enabled: false,
72+
url: '',
73+
account_id: '',
74+
token: '',
75+
sign_msg: false,
76+
name_inbox: '',
77+
webhook_url: '',
78+
};
79+
}
80+
6981
const response = {
7082
...result,
7183
webhook_url: `${urlServer}/chatwoot/webhook/${instance.instanceName}`,
@@ -78,7 +90,7 @@ export class ChatwootController {
7890
logger.verbose(
7991
'requested receiveWebhook from ' + instance.instanceName + ' instance',
8092
);
81-
const chatwootService = new ChatwootService(waMonitor);
93+
const chatwootService = new ChatwootService(waMonitor, this.configService);
8294

8395
return chatwootService.receiveWebhook(instance, data);
8496
}

src/whatsapp/controllers/instance.controller.ts

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ export class InstanceController {
6464
this.repository,
6565
this.cache,
6666
);
67-
instance.instanceName = instanceName;
67+
instance.instanceName = instanceName
68+
.toLowerCase()
69+
.replace(/[^a-z0-9]/g, '')
70+
.replace(' ', '');
6871
this.logger.verbose('instance: ' + instance.instanceName + ' created');
6972

7073
this.waMonitor.waInstances[instance.instanceName] = instance;
@@ -191,7 +194,10 @@ export class InstanceController {
191194
this.repository,
192195
this.cache,
193196
);
194-
instance.instanceName = instanceName;
197+
instance.instanceName = instanceName
198+
.toLowerCase()
199+
.replace(/[^a-z0-9]/g, '')
200+
.replace(' ', '');
195201

196202
this.logger.verbose('instance: ' + instance.instanceName + ' created');
197203

@@ -357,24 +363,8 @@ export class InstanceController {
357363
try {
358364
this.logger.verbose('requested restartInstance from ' + instanceName + ' instance');
359365

360-
this.logger.verbose('deleting instance: ' + instanceName);
361-
delete this.waMonitor.waInstances[instanceName];
362-
363-
this.logger.verbose('creating instance: ' + instanceName);
364-
const instance = new WAStartupService(
365-
this.configService,
366-
this.eventEmitter,
367-
this.repository,
368-
this.cache,
369-
);
370-
371-
instance.instanceName = instanceName;
372-
373-
this.logger.verbose('instance: ' + instance.instanceName + ' created');
374-
375-
this.logger.verbose('connecting instance: ' + instanceName);
376-
await instance.connectToWhatsapp();
377-
this.waMonitor.waInstances[instance.instanceName] = instance;
366+
this.logger.verbose('logging out instance: ' + instanceName);
367+
this.waMonitor.waInstances[instanceName]?.client?.ws?.close();
378368

379369
return { error: false, message: 'Instance restarted' };
380370
} catch (error) {

src/whatsapp/controllers/sendMessage.controller.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,15 @@ export class SendMessageController {
3030

3131
public async sendMedia({ instanceName }: InstanceDto, data: SendMediaDto) {
3232
logger.verbose('requested sendMedia from ' + instanceName + ' instance');
33-
if (isBase64(data?.mediaMessage?.media) && !data?.mediaMessage?.fileName) {
34-
throw new BadRequestException('For bse64 the file name must be informed.');
33+
34+
if (
35+
isBase64(data?.mediaMessage?.media) &&
36+
!data?.mediaMessage?.fileName &&
37+
data?.mediaMessage?.mediatype === 'document'
38+
) {
39+
throw new BadRequestException('For base64 the file name must be informed.');
3540
}
41+
3642
logger.verbose(
3743
'isURL: ' +
3844
isURL(data?.mediaMessage?.media) +

0 commit comments

Comments
 (0)