Skip to content

Commit

Permalink
fix: added cache to identify duplicated messages on events
Browse files Browse the repository at this point in the history
- Update Docker image repository to evoapicloud/evolution-api
- Modify contact email to [email protected]
- 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
  • Loading branch information
DavidsonGomes committed Feb 3, 2025
1 parent 8135994 commit 867e849
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish_docker_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
images: atendai/evolution-api
images: evoapicloud/evolution-api
tags: type=semver,pattern=v{{version}}

- name: Set up QEMU
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish_docker_image_homolog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
images: atendai/evolution-api
images: evoapicloud/evolution-api
tags: homolog

- name: Set up QEMU
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish_docker_image_latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
images: atendai/evolution-api
images: evoapicloud/evolution-api
tags: latest

- name: Set up QEMU
Expand Down
2 changes: 1 addition & 1 deletion Docker/swarm/evolution_api_v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.7"

services:
evolution_v2:
image: atendai/evolution-api:v2.1.2
image: evoapicloud/evolution-api:latest
volumes:
- evolution_instances:/evolution/instances
networks:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ RUN apk update && \

LABEL version="2.2.3" description="Api to control whatsapp features through http requests."
LABEL maintainer="Davidson Gomes" git="https://github.com/DavidsonGomes"
LABEL contact="contato@atendai.com"
LABEL contact="contato@evolution-api.com"

WORKDIR /evolution

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ a. LOGO and copyright information: In the process of using Evolution API's front

b. Usage Notification Requirement: If Evolution API is used as part of any project, including closed-source systems (e.g., proprietary software), the user is required to display a clear notification within the system that Evolution API is being utilized. This notification should be visible to system administrators and accessible from the system's documentation or settings page. Failure to comply with this requirement may result in the necessity for a commercial license, as determined by the producer.

Please contact contato@atendai.com to inquire about licensing matters.
Please contact contato@evolution-api.com to inquire about licensing matters.

2. As a contributor, you should agree that:

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<div align="center">

[![Docker Image (https://img.shields.io/badge/Docker-Image-blue)](https://hub.docker.com/r/evoapicloud/evolution-api)]
[![Whatsapp Group](https://img.shields.io/badge/Group-WhatsApp-%2322BC18)](https://evolution-api.com/whatsapp)
[![Discord Community](https://img.shields.io/badge/Discord-Community-blue)](https://evolution-api.com/discord)
[![Postman Collection](https://img.shields.io/badge/Postman-Collection-orange)](https://evolution-api.com/postman)
Expand Down Expand Up @@ -87,6 +88,7 @@ https://github.com/sponsors/EvolutionAPI
We are proud to collaborate with the following content creators who have contributed valuable insights and tutorials about Evolution API:

- [Promovaweb](https://www.youtube.com/@promovaweb)
- [Sandeco](https://www.youtube.com/@canalsandeco)
- [Comunidade ZDG](https://www.youtube.com/@ComunidadeZDG)
- [Francis MNO](https://www.youtube.com/@FrancisMNO)
- [Pablo Cabral](https://youtube.com/@pablocabral)
Expand All @@ -111,7 +113,7 @@ Evolution API is licensed under the Apache License 2.0, with the following addit

2. **Usage Notification Requirement**: If Evolution API is used as part of any project, including closed-source systems (e.g., proprietary software), the user is required to display a clear notification within the system that Evolution API is being utilized. This notification should be visible to system administrators and accessible from the system's documentation or settings page. Failure to comply with this requirement may result in the necessity for a commercial license, as determined by the producer.

Please contact contato@atendai.com to inquire about licensing matters.
Please contact contato@evolution-api.com to inquire about licensing matters.

Apart from the specific conditions mentioned above, all other rights and restrictions follow the Apache License 2.0. Detailed information about the Apache License 2.0 can be found at [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0).

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
api:
container_name: evolution_api
image: atendai/evolution-api:homolog
image: evoapicloud/evolution-api:latest
restart: always
depends_on:
- redis
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
],
"author": {
"name": "Davidson Gomes",
"email": "contato@atendai.com"
"email": "contato@evolution-api.com"
},
"license": "Apache-2.0",
"bugs": {
Expand Down
22 changes: 22 additions & 0 deletions src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 867e849

Please sign in to comment.