mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-19 11:52:20 -06:00
fix: added cache to identify duplicated messages on events
- Update Docker image repository to evoapicloud/evolution-api - Modify contact email to contato@evolution-api.com - Update Docker Compose, Dockerfile, and workflow files - Add Docker image badge to README - Include additional content creator in README - Implement message deduplication cache in Baileys service
This commit is contained in:
@@ -1161,6 +1161,17 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
await this.baileysCache.delete(received.key.id);
|
||||
}
|
||||
|
||||
// Cache to avoid duplicate messages
|
||||
const messageKey = `${this.instance.id}_${received.key.id}`;
|
||||
const cached = await this.baileysCache.get(messageKey);
|
||||
|
||||
if (cached) {
|
||||
this.logger.info(`Message duplicated ignored: ${received.key.id}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
await this.baileysCache.set(messageKey, true, 30 * 60);
|
||||
|
||||
if (
|
||||
(type !== 'notify' && type !== 'append') ||
|
||||
received.message?.protocolMessage ||
|
||||
@@ -1422,6 +1433,17 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
continue;
|
||||
}
|
||||
|
||||
const updateKey = `${this.instance.id}_${key.id}_${update.status}`;
|
||||
|
||||
const cached = await this.baileysCache.get(updateKey);
|
||||
|
||||
if (cached) {
|
||||
this.logger.info(`Message duplicated ignored: ${key.id}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
await this.baileysCache.set(updateKey, true, 30 * 60);
|
||||
|
||||
if (status[update.status] === 'READ' && key.fromMe) {
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot?.enabled) {
|
||||
this.chatwootService.eventWhatsapp(
|
||||
|
||||
Reference in New Issue
Block a user