Skip to content

Commit 06cde72

Browse files
committed
fix: adjusts in temp folder and return with event send_messages
1 parent 31486e5 commit 06cde72

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

src/whatsapp/services/whatsapp.service.ts

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -984,12 +984,20 @@ export class WAStartupService {
984984
if (
985985
key.remoteJid !== 'status@broadcast' &&
986986
!key?.remoteJid?.match(/(:\d+)/) &&
987-
!key.fromMe
987+
key.fromMe
988988
) {
989+
this.logger.verbose('Message update is valid');
990+
989991
let pollUpdates: any;
990992
if (update.pollUpdates) {
993+
this.logger.verbose('Poll update found');
994+
995+
this.logger.verbose('Getting poll message');
991996
const pollCreation = await this.getMessage(key);
997+
this.logger.verbose(pollCreation);
998+
992999
if (pollCreation) {
1000+
this.logger.verbose('Getting aggregate votes in poll message');
9931001
pollUpdates = getAggregateVotesInPollMessage({
9941002
message: pollCreation as proto.IMessage,
9951003
pollUpdates: update.pollUpdates,
@@ -1005,6 +1013,8 @@ export class WAStartupService {
10051013
pollUpdates,
10061014
};
10071015

1016+
this.logger.verbose(message);
1017+
10081018
this.logger.verbose('Sending data to webhook in event MESSAGES_UPDATE');
10091019
await this.sendDataWebhook(Events.MESSAGES_UPDATE, message);
10101020

@@ -1367,22 +1377,6 @@ export class WAStartupService {
13671377
);
13681378
})();
13691379

1370-
// const messageRaw: proto.IWebMessageInfo = {
1371-
// key: messageSent.key,
1372-
// messageTimestamp: Long.isLong(messageSent.messageTimestamp)
1373-
// ? messageSent.messageTimestamp?.toNumber()
1374-
// : messageSent.messageTimestamp,
1375-
// pushName: messageSent.pushName,
1376-
// broadcast: messageSent.broadcast,
1377-
// status: 2,
1378-
// message: { ...messageSent.message },
1379-
// };
1380-
1381-
// this.client.ev.emit('messages.upsert', {
1382-
// messages: [messageRaw],
1383-
// type: 'notify',
1384-
// });
1385-
13861380
const messageRaw: MessageRaw = {
13871381
key: messageSent.key,
13881382
pushName: messageSent.pushName,
@@ -1395,8 +1389,8 @@ export class WAStartupService {
13951389

13961390
this.logger.log(messageRaw);
13971391

1398-
this.logger.verbose('Sending data to webhook in event MESSAGES_UPSERT');
1399-
await this.sendDataWebhook(Events.MESSAGES_UPSERT, messageRaw);
1392+
this.logger.verbose('Sending data to webhook in event SEND_MESSAGE');
1393+
await this.sendDataWebhook(Events.SEND_MESSAGE, messageRaw);
14001394

14011395
this.logger.verbose('Inserting message in database');
14021396
await this.repository.message.insert(

0 commit comments

Comments
 (0)