Skip to content

Commit 7ab0ebc

Browse files
committed
fix: duplicate message in the database
1 parent 9662c6a commit 7ab0ebc

1 file changed

Lines changed: 4 additions & 16 deletions

File tree

src/whatsapp/services/whatsapp.service.ts

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,8 +1324,6 @@ export class WAStartupService {
13241324
}
13251325
}
13261326

1327-
this.client.ev.emit('messages.upsert', { messages: [m], type: 'notify' });
1328-
13291327
return {
13301328
keyId: m.key.id,
13311329
keyFromMe: m.key.fromMe,
@@ -1358,6 +1356,9 @@ export class WAStartupService {
13581356
this.sendDataWebhook('sendMessage', messageSent).catch((error) =>
13591357
this.logger.error(error),
13601358
);
1359+
this.sendDataWebhook('messagesUpsert', messageSent).catch((error) =>
1360+
this.logger.error(error),
1361+
);
13611362

13621363
return messageSent;
13631364
} catch (error) {
@@ -2093,20 +2094,7 @@ export class WAStartupService {
20932094
});
20942095

20952096
if (!everyOne) {
2096-
await this.client.chatModify(
2097-
{
2098-
clear: {
2099-
messages: [
2100-
{
2101-
id: message.keyId,
2102-
fromMe: message.keyFromMe,
2103-
timestamp: message.messageTimestamp,
2104-
},
2105-
],
2106-
},
2107-
} as any,
2108-
message.keyRemoteJid,
2109-
);
2097+
await this.client.chatModify({ clear: true }, message.keyRemoteJid);
21102098
}
21112099

21122100
await this.client.sendMessage(message.keyRemoteJid, {

0 commit comments

Comments
 (0)