Skip to content

Commit 7e4dbfd

Browse files
committed
fix: Added log when send event to rabbitMQ and Websocket
1 parent 6eda556 commit 7e4dbfd

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

src/libs/amqp.server.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ export const getAMQP = (): amqp.Channel | null => {
4343
};
4444

4545
export const initQueues = (instanceName: string, events: string[]) => {
46-
console.log('initQueues', instanceName, events);
4746
if (!events || !events.length) return;
4847

4948
const queues = events.map((event) => {

src/whatsapp/controllers/instance.controller.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import EventEmitter2 from 'eventemitter2';
55
import { ConfigService, HttpServer } from '../../config/env.config';
66
import { Logger } from '../../config/logger.config';
77
import { BadRequestException, InternalServerErrorException } from '../../exceptions';
8-
import { initQueues } from '../../libs/amqp.server';
98
import { RedisCache } from '../../libs/redis.client';
109
import { InstanceDto } from '../dto/instance.dto';
1110
import { RepositoryBroker } from '../repository/repository.manager';

src/whatsapp/services/whatsapp.service.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,25 @@ export class WAStartupService {
688688
}
689689

690690
amqp.publish(exchangeName, event, Buffer.from(JSON.stringify(message)));
691+
692+
if (this.configService.get<Log>('LOG').LEVEL.includes('WEBHOOKS')) {
693+
const logData = {
694+
local: WAStartupService.name + '.sendData-RabbitMQ',
695+
event,
696+
instance: this.instance.name,
697+
data,
698+
server_url: serverUrl,
699+
apikey: (expose && instanceApikey) || null,
700+
date_time: now,
701+
sender: this.wuid,
702+
};
703+
704+
if (expose && instanceApikey) {
705+
logData['apikey'] = instanceApikey;
706+
}
707+
708+
this.logger.log(logData);
709+
}
691710
}
692711
}
693712
}
@@ -713,6 +732,25 @@ export class WAStartupService {
713732

714733
this.logger.verbose('Sending data to socket.io in channel: ' + this.instance.name);
715734
io.of(`/${this.instance.name}`).emit(event, message);
735+
736+
if (this.configService.get<Log>('LOG').LEVEL.includes('WEBHOOKS')) {
737+
const logData = {
738+
local: WAStartupService.name + '.sendData-Websocket',
739+
event,
740+
instance: this.instance.name,
741+
data,
742+
server_url: serverUrl,
743+
apikey: (expose && instanceApikey) || null,
744+
date_time: now,
745+
sender: this.wuid,
746+
};
747+
748+
if (expose && instanceApikey) {
749+
logData['apikey'] = instanceApikey;
750+
}
751+
752+
this.logger.log(logData);
753+
}
716754
}
717755
}
718756

0 commit comments

Comments
 (0)