@@ -16,81 +16,101 @@ import { ContactQuery } from '../repository/contact.repository';
1616import { MessageQuery } from '../repository/message.repository' ;
1717import { MessageUpQuery } from '../repository/messageUp.repository' ;
1818import { WAMonitoringService } from '../services/monitor.service' ;
19+ import { Logger } from '../../config/logger.config' ;
20+
21+ const logger = new Logger ( 'ChatController' ) ;
1922
2023export class ChatController {
2124 constructor ( private readonly waMonitor : WAMonitoringService ) { }
2225
2326 public async whatsappNumber ( { instanceName } : InstanceDto , data : WhatsAppNumberDto ) {
27+ logger . verbose ( 'requested whatsappNumber from ' + instanceName + ' instance' ) ;
2428 return await this . waMonitor . waInstances [ instanceName ] . whatsappNumber ( data ) ;
2529 }
2630
2731 public async readMessage ( { instanceName } : InstanceDto , data : ReadMessageDto ) {
32+ logger . verbose ( 'requested readMessage from ' + instanceName + ' instance' ) ;
2833 return await this . waMonitor . waInstances [ instanceName ] . markMessageAsRead ( data ) ;
2934 }
3035
3136 public async archiveChat ( { instanceName } : InstanceDto , data : ArchiveChatDto ) {
37+ logger . verbose ( 'requested archiveChat from ' + instanceName + ' instance' ) ;
3238 return await this . waMonitor . waInstances [ instanceName ] . archiveChat ( data ) ;
3339 }
3440
3541 public async deleteMessage ( { instanceName } : InstanceDto , data : DeleteMessage ) {
42+ logger . verbose ( 'requested deleteMessage from ' + instanceName + ' instance' ) ;
3643 return await this . waMonitor . waInstances [ instanceName ] . deleteMessage ( data ) ;
3744 }
3845
3946 public async fetchProfilePicture ( { instanceName } : InstanceDto , data : NumberDto ) {
47+ logger . verbose ( 'requested fetchProfilePicture from ' + instanceName + ' instance' ) ;
4048 return await this . waMonitor . waInstances [ instanceName ] . profilePicture ( data . number ) ;
4149 }
4250
4351 public async fetchContacts ( { instanceName } : InstanceDto , query : ContactQuery ) {
52+ logger . verbose ( 'requested fetchContacts from ' + instanceName + ' instance' ) ;
4453 return await this . waMonitor . waInstances [ instanceName ] . fetchContacts ( query ) ;
4554 }
4655
4756 public async getBase64FromMediaMessage (
4857 { instanceName } : InstanceDto ,
4958 data : getBase64FromMediaMessageDto ,
5059 ) {
60+ logger . verbose (
61+ 'requested getBase64FromMediaMessage from ' + instanceName + ' instance' ,
62+ ) ;
5163 return await this . waMonitor . waInstances [ instanceName ] . getBase64FromMediaMessage ( data ) ;
5264 }
5365
5466 public async fetchMessages ( { instanceName } : InstanceDto , query : MessageQuery ) {
67+ logger . verbose ( 'requested fetchMessages from ' + instanceName + ' instance' ) ;
5568 return await this . waMonitor . waInstances [ instanceName ] . fetchMessages ( query ) ;
5669 }
5770
5871 public async fetchStatusMessage ( { instanceName } : InstanceDto , query : MessageUpQuery ) {
72+ logger . verbose ( 'requested fetchStatusMessage from ' + instanceName + ' instance' ) ;
5973 return await this . waMonitor . waInstances [ instanceName ] . fetchStatusMessage ( query ) ;
6074 }
6175
6276 public async fetchChats ( { instanceName } : InstanceDto ) {
77+ logger . verbose ( 'requested fetchChats from ' + instanceName + ' instance' ) ;
6378 return await this . waMonitor . waInstances [ instanceName ] . fetchChats ( ) ;
6479 }
6580
6681 public async fetchPrivacySettings ( { instanceName } : InstanceDto ) {
82+ logger . verbose ( 'requested fetchPrivacySettings from ' + instanceName + ' instance' ) ;
6783 return await this . waMonitor . waInstances [ instanceName ] . fetchPrivacySettings ( ) ;
6884 }
6985
7086 public async updatePrivacySettings (
7187 { instanceName } : InstanceDto ,
7288 data : PrivacySettingDto ,
7389 ) {
90+ logger . verbose ( 'requested updatePrivacySettings from ' + instanceName + ' instance' ) ;
7491 return await this . waMonitor . waInstances [ instanceName ] . updatePrivacySettings ( data ) ;
7592 }
7693
7794 public async fetchBusinessProfile (
7895 { instanceName } : InstanceDto ,
7996 data : ProfilePictureDto ,
8097 ) {
98+ logger . verbose ( 'requested fetchBusinessProfile from ' + instanceName + ' instance' ) ;
8199 return await this . waMonitor . waInstances [ instanceName ] . fetchBusinessProfile (
82100 data . number ,
83101 ) ;
84102 }
85103
86104 public async updateProfileName ( { instanceName } : InstanceDto , data : ProfileNameDto ) {
105+ logger . verbose ( 'requested updateProfileName from ' + instanceName + ' instance' ) ;
87106 return await this . waMonitor . waInstances [ instanceName ] . updateProfileName ( data . name ) ;
88107 }
89108
90109 public async updateProfileStatus (
91110 { instanceName } : InstanceDto ,
92111 data : ProfileStatusDto ,
93112 ) {
113+ logger . verbose ( 'requested updateProfileStatus from ' + instanceName + ' instance' ) ;
94114 return await this . waMonitor . waInstances [ instanceName ] . updateProfileStatus (
95115 data . status ,
96116 ) ;
@@ -100,6 +120,7 @@ export class ChatController {
100120 { instanceName } : InstanceDto ,
101121 data : ProfilePictureDto ,
102122 ) {
123+ logger . verbose ( 'requested updateProfilePicture from ' + instanceName + ' instance' ) ;
103124 return await this . waMonitor . waInstances [ instanceName ] . updateProfilePicture (
104125 data . picture ,
105126 ) ;
@@ -109,6 +130,7 @@ export class ChatController {
109130 { instanceName } : InstanceDto ,
110131 data : ProfilePictureDto ,
111132 ) {
133+ logger . verbose ( 'requested removeProfilePicture from ' + instanceName + ' instance' ) ;
112134 return await this . waMonitor . waInstances [ instanceName ] . removeProfilePicture ( ) ;
113135 }
114136}
0 commit comments