Skip to content

Commit 437803d

Browse files
committed
feat: Added verbose logs
1 parent a7be7c3 commit 437803d

11 files changed

Lines changed: 542 additions & 1 deletion

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
* Adjusted set in webhook to go empty when enabled false
1010
* Adjust in store files
11+
* Added verbose logs
1112

1213
# 1.1.3 (2023-07-06 11:43)
1314

src/whatsapp/controllers/chat.controller.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,81 +16,101 @@ import { ContactQuery } from '../repository/contact.repository';
1616
import { MessageQuery } from '../repository/message.repository';
1717
import { MessageUpQuery } from '../repository/messageUp.repository';
1818
import { WAMonitoringService } from '../services/monitor.service';
19+
import { Logger } from '../../config/logger.config';
20+
21+
const logger = new Logger('ChatController');
1922

2023
export 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
}

src/whatsapp/controllers/group.controller.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,31 @@ import {
1212
} from '../dto/group.dto';
1313
import { InstanceDto } from '../dto/instance.dto';
1414
import { WAMonitoringService } from '../services/monitor.service';
15+
import { Logger } from '../../config/logger.config';
16+
17+
const logger = new Logger('ChatController');
1518

1619
export class GroupController {
1720
constructor(private readonly waMonitor: WAMonitoringService) {}
1821

1922
public async createGroup(instance: InstanceDto, create: CreateGroupDto) {
23+
logger.verbose('requested createGroup from ' + instance.instanceName + ' instance');
2024
return await this.waMonitor.waInstances[instance.instanceName].createGroup(create);
2125
}
2226

2327
public async updateGroupPicture(instance: InstanceDto, update: GroupPictureDto) {
28+
logger.verbose(
29+
'requested updateGroupPicture from ' + instance.instanceName + ' instance',
30+
);
2431
return await this.waMonitor.waInstances[instance.instanceName].updateGroupPicture(
2532
update,
2633
);
2734
}
2835

2936
public async updateGroupSubject(instance: InstanceDto, update: GroupSubjectDto) {
37+
logger.verbose(
38+
'requested updateGroupSubject from ' + instance.instanceName + ' instance',
39+
);
3040
return await this.waMonitor.waInstances[instance.instanceName].updateGroupSubject(
3141
update,
3242
);
@@ -36,38 +46,54 @@ export class GroupController {
3646
instance: InstanceDto,
3747
update: GroupDescriptionDto,
3848
) {
49+
logger.verbose(
50+
'requested updateGroupDescription from ' + instance.instanceName + ' instance',
51+
);
3952
return await this.waMonitor.waInstances[instance.instanceName].updateGroupDescription(
4053
update,
4154
);
4255
}
4356

4457
public async findGroupInfo(instance: InstanceDto, groupJid: GroupJid) {
58+
logger.verbose('requested findGroupInfo from ' + instance.instanceName + ' instance');
4559
return await this.waMonitor.waInstances[instance.instanceName].findGroup(groupJid);
4660
}
4761

4862
public async fetchAllGroups(instance: InstanceDto) {
63+
logger.verbose(
64+
'requested fetchAllGroups from ' + instance.instanceName + ' instance',
65+
);
4966
return await this.waMonitor.waInstances[instance.instanceName].fetchAllGroups();
5067
}
5168

5269
public async inviteCode(instance: InstanceDto, groupJid: GroupJid) {
70+
logger.verbose('requested inviteCode from ' + instance.instanceName + ' instance');
5371
return await this.waMonitor.waInstances[instance.instanceName].inviteCode(groupJid);
5472
}
5573

5674
public async inviteInfo(instance: InstanceDto, inviteCode: GroupInvite) {
75+
logger.verbose('requested inviteInfo from ' + instance.instanceName + ' instance');
5776
return await this.waMonitor.waInstances[instance.instanceName].inviteInfo(inviteCode);
5877
}
5978

6079
public async sendInvite(instance: InstanceDto, data: GroupSendInvite) {
80+
logger.verbose('requested sendInvite from ' + instance.instanceName + ' instance');
6181
return await this.waMonitor.waInstances[instance.instanceName].sendInvite(data);
6282
}
6383

6484
public async revokeInviteCode(instance: InstanceDto, groupJid: GroupJid) {
85+
logger.verbose(
86+
'requested revokeInviteCode from ' + instance.instanceName + ' instance',
87+
);
6588
return await this.waMonitor.waInstances[instance.instanceName].revokeInviteCode(
6689
groupJid,
6790
);
6891
}
6992

7093
public async findParticipants(instance: InstanceDto, groupJid: GroupJid) {
94+
logger.verbose(
95+
'requested findParticipants from ' + instance.instanceName + ' instance',
96+
);
7197
return await this.waMonitor.waInstances[instance.instanceName].findParticipants(
7298
groupJid,
7399
);
@@ -77,22 +103,32 @@ export class GroupController {
77103
instance: InstanceDto,
78104
update: GroupUpdateParticipantDto,
79105
) {
106+
logger.verbose(
107+
'requested updateGParticipate from ' + instance.instanceName + ' instance',
108+
);
80109
return await this.waMonitor.waInstances[instance.instanceName].updateGParticipant(
81110
update,
82111
);
83112
}
84113

85114
public async updateGSetting(instance: InstanceDto, update: GroupUpdateSettingDto) {
115+
logger.verbose(
116+
'requested updateGSetting from ' + instance.instanceName + ' instance',
117+
);
86118
return await this.waMonitor.waInstances[instance.instanceName].updateGSetting(update);
87119
}
88120

89121
public async toggleEphemeral(instance: InstanceDto, update: GroupToggleEphemeralDto) {
122+
logger.verbose(
123+
'requested toggleEphemeral from ' + instance.instanceName + ' instance',
124+
);
90125
return await this.waMonitor.waInstances[instance.instanceName].toggleEphemeral(
91126
update,
92127
);
93128
}
94129

95130
public async leaveGroup(instance: InstanceDto, groupJid: GroupJid) {
131+
logger.verbose('requested leaveGroup from ' + instance.instanceName + ' instance');
96132
return await this.waMonitor.waInstances[instance.instanceName].leaveGroup(groupJid);
97133
}
98134
}

0 commit comments

Comments
 (0)