Skip to content

Commit e51b6e9

Browse files
committed
fix: improve message deduplication and edited message handling in Baileys service
- Refactor edited message detection logic - Prevent duplicate message processing for edited messages - Optimize message key caching mechanism
1 parent 867e849 commit e51b6e9

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
/dist
33
/node_modules
44

5+
.cursor*
6+
57
/Docker/.env
68

79
.vscode

src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,9 +1128,10 @@ export class BaileysStartupService extends ChannelStartupService {
11281128
}
11291129
}
11301130

1131+
const editedMessage =
1132+
received?.message?.protocolMessage || received?.message?.editedMessage?.message?.protocolMessage;
1133+
11311134
if (received.message?.protocolMessage?.editedMessage || received.message?.editedMessage?.message) {
1132-
const editedMessage =
1133-
received.message?.protocolMessage || received.message?.editedMessage?.message?.protocolMessage;
11341135
if (editedMessage) {
11351136
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot?.enabled)
11361137
this.chatwootService.eventWhatsapp(
@@ -1165,7 +1166,7 @@ export class BaileysStartupService extends ChannelStartupService {
11651166
const messageKey = `${this.instance.id}_${received.key.id}`;
11661167
const cached = await this.baileysCache.get(messageKey);
11671168

1168-
if (cached) {
1169+
if (cached && !editedMessage) {
11691170
this.logger.info(`Message duplicated ignored: ${received.key.id}`);
11701171
continue;
11711172
}

0 commit comments

Comments
 (0)