chore: Bump version to 1.8.4 and update logging in services

- Updated package version from 1.8.2 to 1.8.4 in package.json.
- Refactored instance.controller.ts to allow logout for both 'connecting' and 'open' states, improving instance management.
- Commented out unnecessary logging in channel.service.ts to enhance code clarity.
- Enhanced logging in whatsapp.baileys.service.ts to include instance details in CONNECTION_UPDATE events, improving webhook data sent during connection state changes.

These changes improve versioning, code clarity, and logging functionality across the application.
This commit is contained in:
Davidson Gomes 2025-01-17 15:40:36 -03:00
parent 6ddad8e85a
commit 03ee40388c
4 changed files with 39 additions and 20 deletions

View File

@ -1,6 +1,6 @@
{
"name": "evolution-api",
"version": "1.8.2",
"version": "1.8.4",
"description": "Rest api for communication with WhatsApp",
"main": "./dist/src/main.js",
"scripts": {

View File

@ -737,16 +737,11 @@ export class InstanceController {
this.logger.verbose('requested deleteInstance from ' + instanceName + ' instance');
const { instance } = await this.connectionState({ instanceName });
if (instance.state === 'open') {
throw new BadRequestException('The "' + instanceName + '" instance needs to be disconnected');
}
try {
this.waMonitor.waInstances[instanceName]?.removeRabbitmqQueues();
this.waMonitor.waInstances[instanceName]?.clearCacheChatwoot();
if (instance.state === 'connecting') {
this.logger.verbose('logging out instance: ' + instanceName);
if (instance.state === 'connecting' || instance.state === 'open') {
await this.logout({ instanceName });
}

View File

@ -766,7 +766,7 @@ export class ChannelStartupService {
logData['apikey'] = instanceApikey;
}
this.logger.log(logData);
// this.logger.log(logData);
}
break;
} catch (error) {
@ -834,7 +834,7 @@ export class ChannelStartupService {
logData['apikey'] = instanceApikey;
}
this.logger.log(logData);
// this.logger.log(logData);
}
break;
@ -907,7 +907,7 @@ export class ChannelStartupService {
logData['apikey'] = instanceApikey;
}
this.logger.log(logData);
// this.logger.log(logData);
}
}
});
@ -951,7 +951,7 @@ export class ChannelStartupService {
logData['apikey'] = instanceApikey;
}
this.logger.log(logData);
// this.logger.log(logData);
}
}
@ -981,7 +981,7 @@ export class ChannelStartupService {
logData['apikey'] = instanceApikey;
}
this.logger.log(logData);
// this.logger.log(logData);
}
}
}
@ -1017,7 +1017,7 @@ export class ChannelStartupService {
logData['apikey'] = instanceApikey;
}
this.logger.log(logData);
// this.logger.log(logData);
}
try {
@ -1088,7 +1088,7 @@ export class ChannelStartupService {
logData['apikey'] = globalApiKey;
}
this.logger.log(logData);
// this.logger.log(logData);
}
try {

View File

@ -379,12 +379,6 @@ export class BaileysStartupService extends ChannelStartupService {
state: connection,
statusReason: (lastDisconnect?.error as Boom)?.output?.statusCode ?? 200,
};
this.logger.verbose('Sending data to webhook in event CONNECTION_UPDATE');
this.sendDataWebhook(Events.CONNECTION_UPDATE, {
instance: this.instance.name,
...this.stateConnection,
});
}
if (connection === 'close') {
@ -417,6 +411,15 @@ export class BaileysStartupService extends ChannelStartupService {
this.client?.ws?.close();
this.client.end(new Error('Close connection'));
this.logger.verbose('Connection closed');
this.logger.verbose('Sending data to webhook in event CONNECTION_UPDATE');
this.sendDataWebhook(Events.CONNECTION_UPDATE, {
instance: this.instance.name,
wuid: this.instance.wuid,
profileName: await this.getProfileName(),
profilePictureUrl: this.instance.profilePictureUrl,
...this.stateConnection,
});
}
}
@ -446,13 +449,34 @@ export class BaileysStartupService extends ChannelStartupService {
{
instance: this.instance.name,
status: 'open',
wuid: this.instance.wuid,
profileName: await this.getProfileName(),
profilePictureUrl: this.instance.profilePictureUrl,
},
);
}
this.logger.verbose('Sending data to webhook in event CONNECTION_UPDATE');
this.sendDataWebhook(Events.CONNECTION_UPDATE, {
instance: this.instance.name,
wuid: this.instance.wuid,
profileName: await this.getProfileName(),
profilePictureUrl: this.instance.profilePictureUrl,
...this.stateConnection,
});
}
if (connection === 'connecting') {
if (this.mobile) this.sendMobileCode();
this.logger.verbose('Sending data to webhook in event CONNECTION_UPDATE');
this.sendDataWebhook(Events.CONNECTION_UPDATE, {
instance: this.instance.name,
wuid: this.instance.wuid,
profileName: await this.getProfileName(),
profilePictureUrl: this.instance.profilePictureUrl,
...this.stateConnection,
});
}
}