Commit Graph

1324 Commits

Author SHA1 Message Date
Davidson Gomes
26bddf3c53 Add support for managing WhatsApp templates via official API
This commit introduces changes to support managing WhatsApp templates using the official WhatsApp Business API. The following modifications have been made:

- Implemented a new Template model in the Prisma schema, including fields for template ID, name, language, and associated Instance (business ID, instance ID, and created/updated timestamps).
- Modified the Instance model in the Prisma schema to include a Template relationship.
- Updated InstanceController to include a new `businessId` property in the InstanceDto.
- Added a new TemplateRouter, TemplateController, and TemplateService to handle template-related requests and services.
- Updated the WebhookService to utilize the new TemplateService.
- Added new TypebotController, WebhookController, and WAMonitoringService methods to handle template-related events.
- Updated the validate schema to include a new template schema.

The main goal of this commit is to enable managing WhatsApp templates, including creating, updating, and deleting templates, as well as associating them with specific instances.
2024-07-12 12:32:44 -03:00
Davidson Gomes
a145935366 chore: Add businessId to Instance model
Updated the Instance model to include a new optional string property called businessId. This change affects the following files:

- prisma/postgresql-schema.prisma
- src/api/controllers/instance.controller.ts
- src/api/dto/instance.dto.ts
- src/api/services/monitor.service.ts
- src/validate/instance.schema.ts

A new untracked migration folder has been created to manage database schema updates:

- prisma/migrations/20240712144948_add_business_id_column_to_instances/

This change allows for storing a business identifier alongside the instance, enhancing the ability to categorize and manage instances more effectively.
2024-07-12 11:52:29 -03:00
Davidson Gomes
f6d4f940a3 chore: Update cloud API message sending for lists and buttons
This commit updates the way messages are sent to the cloud API for lists and buttons,
adjusting the structure of the request payload. The affected files include:
- sendMessage.dto.ts: updates the format of the Button class
- sendMessage.router.ts: adds a new route for sending button messages
- whatsapp.business.service.ts: updates the handling of list and button messages
- message.schema.ts: adds a new schema for button messages

These changes improve the integration with the cloud API and allow for better handling of lists and buttons in messages.
2024-07-12 09:40:15 -03:00
Davidson Gomes
4737c71ae1 refactor: change webhook reception for all instances
This commit refactors the webhook reception to handle all instances at once. Previously, each instance had its own webhook endpoint, but now there is a single endpoint for all instances. This change simplifies the codebase and reduces the potential for errors.

The main changes include:
- Modifying the `InstanceController` to update the webhook URL for all instances.
- Modifying the `WebhookController` to handle the reception of webhooks for all instances.
- Modifying the `IndexRouter` and `WebhookRouter` to add a new route for the webhook reception endpoint.
- Modifying the `ServerModule` to inject the `PrismaRepository` into the `WebhookService`.
- Modifying the `WebhookService` to handle the reception of webhooks for all instances.

These changes improve the maintainability and scalability of the application, as there is no longer a need to manage individual webhook endpoints for each instance.
2024-07-12 08:52:18 -03:00
Davidson Gomes
90e03e6d1e ajuste 2024-07-03 18:58:57 -03:00
Davidson Gomes
3637b95f8f chore: Update Dockerfile and whatsapp.baileys.service.ts
Update and modifications in Dockerfile and src/api/services/channels/whatsapp.baileys.service.ts files. These changes improve the performance and maintainability of the Node.js project.
2024-07-03 18:35:12 -03:00
Davidson Gomes
b3a0899f4f chore: Update GitHub actions workflow
Update the GitHub actions workflow file to improve the CI/CD pipeline. The changes include modifying the existing `publish_docker_image_v2.yml` file. These changes ensure the project's version 2.0.0 remains up-to-date and compatible with the latest GitHub actions and Docker image publishing process.
2024-07-03 18:04:52 -03:00
Davidson Gomes
ebc78d63ac chore: Update GitHub Actions workflow in v2.0.0
Update to the GitHub Actions workflow in the v2.0.0 branch. This change modifies the
`.github/workflows/publish_docker_image_v2.yml` file, which is part of the CI/CD
pipeline for publishing Docker images. The specific modifications and their impact
are not detailed in the provided information.
2024-07-03 18:01:34 -03:00
Davidson Gomes
7e48f1bba1 chore: Update WhatsApp Baileys service
Updated the WhatsApp Baileys service at 'src/api/services/channels/whatsapp.baileys.service.ts' to improve test coverage and reliability. This change does not alter the functionality of the service but enhances its maintainability.
2024-07-03 17:59:43 -03:00
Davidson Gomes
aab62e4b03 chore: Update CHANGELOG, Dockerfile and add CI workflow for publishing latest Docker image
- Update CHANGELOG.md to include the new Docker workflow
- Update Dockerfile to improve the build process
- Add a new GitHub Actions workflow (.github/workflows/publish\_docker\_image\_latest.yml) to publish the latest Docker image on push to the 'v2.0.0' branch

This change allows for easier deployment of the latest version of the application, with an updated Dockerfile and a new GitHub Actions workflow to handle publishing the Docker image.
2024-07-03 17:25:38 -03:00
Davidson Gomes
6cea02252e chore: Clear logs in Whatsapp Baileys Service
This commit removes console logs from the Whatsapp Baileys Service in the `whatsapp.baileys.service.ts` file. The logs that were removed were not necessary for the functionality of the service and were only used for debugging purposes. By removing them, we improve the performance and readability of the code.

Modified files:
- src/api/services/channels/whatsapp.baileys.service.ts
2024-07-03 13:22:09 -03:00
Davidson Gomes
8e72983304 fix: Correction in the generation of the queue name 'rabbit'
Fixes a bug in the generation of the 'rabbit' queue name in the 'channel.service.ts' file. The variable 'transformedWe' was replaced by 'event' to generate the queue name. This ensures that the queue name is generated correctly, avoiding possible errors or malfunctions in the system.
2024-06-30 11:25:12 -03:00
Davidson Gomes
b5683aed2a chore: Update 'baileys' dependency to use 'EvolutionAPI' repository
The 'baileys' dependency in the 'package.json' file has been updated to use the 'EvolutionAPI' repository instead of 'WhiskeySockets'. This change ensures that the latest version of 'baileys' is used, which includes improvements in group message sending and cache utilization.

Modified files:
- package.json
2024-06-27 17:49:48 -03:00
Davidson Gomes
228dcf8aa5 chore: Improve code consistency and readability
Refactored the initialization of `LocalSettings` in `channel.service.ts` to only set the properties that have been explicitly provided. This refactoring improves code consistency and readability. Also, removed the unused `initStoreFolders` method from `repository.service.ts` and its related imports. In addition, updated the import style for `PrismaClient` in `repository.service.ts`.

The modified files are:
- src/api/controllers/instance.controller.ts
- src/api/repository/repository.service.ts
- src/api/services/channel.service.ts
- src/api/services/channels/whatsapp.baileys.service.ts
2024-06-27 09:01:02 -03:00
Davidson Gomes
457628b996 fix: Adjusted group message sending with cache improvement
This commit addresses an adjustment in the process of sending messages to groups, with a focus on improving cache utilization. The main modifications include:

- Updated 'package.json' to use the latest 'baileys' version from 'WhiskeySockets' repository.
- Modified 'src/api/services/channels/whatsapp.baileys.service.ts' for better handling of group metadata cache.

The force update group metadata cache function has been removed to streamline the codebase and improve cache handling. This change will ensure that group metadata is updated more efficiently and reduce the overall processing time.
2024-06-27 02:02:34 -03:00
Davidson Gomes
5ea276398f chore: Improve performance of status update and message sending in groups
The performance of sending status updates and messages in groups has been significantly improved. The batch size for sending messages has been reduced from 200 to 1, which allows for more efficient processing.

The `whatsapp.baileys.service.ts` file has been modified to implement this change. The previous batch size was set to 200, which has been updated to 1. This change reduces the number of participants processed in each batch, resulting in improved performance.

This modification also includes a conditional statement to ensure that no further processing is performed when there are no more batches left. This enhancement aims to optimize the overall process of sending status updates and messages in groups.
2024-06-26 23:22:51 -03:00
Davidson Gomes
d342a7b621 chore: Refactor WAMonitoringService instance retrieval and improve code readability
Refactored WAMonitoringService to retrieve instances using Prisma's `findMany` method with a dynamic `where` clause.
This change simplifies the code and makes it more maintainable.
It also removes the deprecated `for...of` loop and the unnecessary instantiation of objects.
The new implementation provides better performance and is more aligned with the current best practices.

Modified files:
- src/api/services/monitor.service.ts
2024-06-26 19:27:06 -03:00
Davidson Gomes
b70ab5a4c3 fix: Update message function to support different message types
The updateMessage function was updated to support different message types such as text, image, and video.
A new private function formatUpdateMessage was added to handle the logic of formatting the message based on its type.
The function checks the message type and returns the corresponding format for the message.
If the message type is not supported, it will return null and throw a BadRequestException.
The createJid function is now called in the updateMessage function to get the jid of the recipient.
This change improves the flexibility of the updateMessage function and ensures that it can handle different types of messages.
2024-06-26 18:23:18 -03:00
Davidson Gomes
6cb3357f08 fix: Correction in WhatsApp sticker sending
Corrected an issue where stickers were not being sent properly in WhatsApp channels. The bug was caused by a mistake in the 'src/api/services/channels/whatsapp.baileys.service.ts' file. This fix resolves the problem and ensures that stickers are sent correctly in WhatsApp channels.
2024-06-26 17:52:51 -03:00
Davidson Gomes
99f4fe2e43 fix: Ghost emoji correction in message sending
Corrects an issue where a ghost emoji was being displayed in message sending. The 'Mentions' class was removed and its properties were moved to the 'Options' class. The 'everyOne' and 'mentioned' properties were replaced by 'mentionsEveryOne' and 'mentioned', respectively. This change improves the code readability and maintainability.

The affected files are:
- src/api/dto/sendMessage.dto.ts
- src/api/services/channels/whatsapp.baileys.service.ts
- src/api/services/channels/whatsapp.business.service.ts
2024-06-26 17:27:38 -03:00
Davidson Gomes
0ded76d366 chore: Recover lost messages from cache in WhatsApp Baileys service 2024-06-26 16:57:55 -03:00
Davidson Gomes
a737fed5cb chore: Updated WhatsApp baileys service
Modified the WhatsApp baileys service to improve the overall functionality. This change aims to enhance the user experience and maintain code quality.

Please note that only the 'src/api/services/channels/whatsapp.baileys.service.ts' file has been modified.
2024-06-26 16:13:21 -03:00
Davidson Gomes
79cadadcc7 chore: Update group metadata cache (#GI234)
- Updated the group metadata cache to improve performance.
- Added verbose logging for cache updates and requests.
- Affected file: `whatsapp.baileys.service.ts`.

Please note that this change does not alter the functionality or behavior of the application. It is a maintenance task to optimize cache management.
2024-06-26 15:38:04 -03:00
Davidson Gomes
75922e603b chore: Update group metadata cache on participants update
Refactored WhatsappBaileysService to update group metadata cache when a participants update event is triggered. This will improve the accuracy of the group metadata and ensure that it stays up-to-date with the latest changes in the group.

Modified:
- src/api/services/channels/whatsapp.baileys.service.ts
2024-06-26 15:23:06 -03:00
Davidson Gomes
d0eee796ba fix: Resolve generation of pairing code
In this commit, we have fixed an issue related to the generation of the pairing code. The changes include modifying the `whatsapp.baileys.service.ts` file, where we have updated the `connectToWhatsapp` method to accept a phone number parameter. Additionally, we have made changes to the `browser` variable to handle phone number and browser options. These changes improve the reliability of the pairing code generation.
2024-06-26 13:55:11 -03:00
Davidson Gomes
47d6fd5d31 chore: Update privacy settings, refactor code and improve performance
In this commit, several changes were made to improve the codebase and update privacy settings. Specifically, the following changes were made:

- The `PrivacySetting` class was refactored to `PrivacySettingDto` in `chat.dto.ts`.
- The `put` method was changed to `post` in `chat.router.ts` for updating the profile picture.
- Several methods in `channel.service.ts` were refactored to improve performance and readability. Specifically, the `setWebhook`, `setRabbitmq`, `setSqs`, `fetchContacts`, and `fetchMessages` methods were improved.
- The `updatePrivacySettings` method in `whatsapp.baileys.service.ts` was refactored to reduce complexity and improve readability.

These changes were made to improve the overall performance and maintainability of the codebase. Additionally, the privacy settings for the WhatsApp client were updated to provide better control over user data.
2024-06-26 08:08:12 -03:00
Davidson Gomes
4120318ec4 feat: update dependencies and improve channel services
Updated dependencies in package.json to ensure compatibility and performance. Enhanced functionality in channel.service.ts and whatsapp.baileys.service.ts for better service handling and reliability. This update aims to improve overall system stability and performance.
2024-06-18 11:28:10 -03:00
Davidson Gomes
4349959daa
Merge pull request #647 from francisbreit/evolution-api-v2.0.0-alpha-fr1
Update criador_de_inbox.json for Evolution v2.0
2024-06-17 14:28:38 -03:00
Davidson Gomes
549224ac16 fix: update WhatsApp Baileys service
Modified the WhatsApp Baileys service in channels to fix an issue. This change addresses a bug that was causing incorrect message handling. The update ensures more reliable communication through the WhatsApp API.
2024-06-17 13:48:46 -03:00
Davidson Gomes
d45e303d55 fix: add TypeScript types to use-multi-file-auth-state-prisma.ts functions
Added TypeScript types to functions in use-multi-file-auth-state-prisma.ts to improve type safety and code readability. This change helps catch type-related errors during development and enhances the maintainability of the codebase.
2024-06-17 13:42:18 -03:00
Davidson Gomes
85106667a2 feat: update message sending logic
Refactored sendMessage.controller.ts, chat.dto.ts, and sendMessage.dto.ts to improve message handling. Updated chatwoot.service.ts and sendMessage.router.ts for better integration with Chatwoot. Enhanced whatsapp.baileys.service.ts for more reliable WhatsApp communication. Adjusted chat.schema.ts and message.schema.ts for validation improvements. These changes enhance the overall messaging functionality and reliability.
2024-06-15 12:46:52 -03:00
Francis Breit
371ab944b3
Update criador_de_inbox.json for Evolution v2.0
Update criador_de_inbox.json for Evolution v2.0
2024-06-14 13:16:42 -03:00
Davidson Gomes
2d49c73023 fix: add validation to prevent group calls in whatsapp.baileys.service.ts
Added a check to prevent group calls by throwing a BadRequestException when a group JID is detected. This change ensures that only individual calls are processed, preventing unsupported group call attempts and improving error handling.
2024-06-14 09:45:02 -03:00
Davidson Gomes
92a0d8ccc9 feat: update API routes and services for better cache handling
Modified instance.router.ts to change HTTP method from PUT to POST for 'restart' route. Updated whatsapp.baileys.service.ts to correct cache configuration logic, ensuring proper usage of cached group metadata. Removed obsolete Typebot-related schema definitions from instance.schema.ts for cleaner validation. These changes improve API functionality and maintainability.
2024-06-14 09:25:18 -03:00
Davidson Gomes
7dfc09ff16 feat: update Baileys library and add fake call feature
Updated the Baileys library reference in package.json and refactored imports across multiple files to use the new library. Added a new feature to handle fake calls in sendMessage.controller.ts and related DTOs. This change improves the integration with the Baileys library and introduces the ability to simulate calls, enhancing the testing capabilities. Main files modified: package.json, instance.controller.ts, sendMessage.controller.ts, chat.dto.ts, instance.dto.ts, sendMessage.dto.ts, chatwoot.service.ts, chatwoot-import-helper.ts, sendMessage.router.ts, cache.service.ts, channel.service.ts, whatsapp.baileys.service.ts, whatsapp.business.service.ts, wa.types.ts, rediscache.ts, use-multi-file-auth-state-prisma.ts, use-multi-file-auth-state-provider-files.ts, use-multi-file-auth-state-redis-db.ts, message.schema.ts.
2024-06-14 08:44:19 -03:00
Davidson Gomes
61d6ddfa81 fix: update default values for WA_BUSINESS configuration
Updated the default values for TOKEN_WEBHOOK, URL, and VERSION in the WA_BUSINESS configuration. This change ensures that the application has more meaningful default settings, improving the initial setup experience. The impact is limited to default behavior when environment variables are not set.
2024-06-13 18:53:20 -03:00
Davidson Gomes
06ba1fd17b chore: update baileys version in package.json
Updated the baileys version in package.json to ensure compatibility with the latest features and bug fixes. This change is necessary to maintain the stability and performance of the application.
2024-06-12 18:56:17 -03:00
Davidson Gomes
f1c31a70bc fix: adjust settings in whatsapp.baileys.service.ts
Increased retryRequestDelayMs, added maxMsgRetryCount, and updated connectTimeoutMs and qrTimeout values for better performance. Adjusted transactionOpts for more efficient retries. These changes aim to enhance connection stability and message handling efficiency.
2024-06-12 18:39:57 -03:00
Davidson Gomes
7799e6626f fix: baileys ignore newsletter 2024-06-12 15:42:37 -03:00
Davidson Gomes
aa79c1bfd7 feat: tagging in chatwoot contact by instance 2024-06-12 15:18:37 -03:00
Davidson Gomes
7451b0d1e3 feat: tagging in chatwoot contact by instance 2024-06-12 15:18:26 -03:00
Davidson Gomes
18d4c68025 fix: messageId baileys 2024-06-12 11:23:51 -03:00
Davidson Gomes
a7887f0b1c fix: messageId baileys 2024-06-12 09:55:40 -03:00
Davidson Gomes
fa14b7b1a9 feat: Added debounce time for typebot messages 2024-06-11 17:56:45 -03:00
Davidson Gomes
2776f113cb feat: Added debounce time for typebot messages 2024-06-11 17:56:20 -03:00
Davidson Gomes
0bf8e55144 fix: provider variables are no longer mandatory in the env 2024-06-11 13:06:35 -03:00
Davidson Gomes
87c68df0f6 fix: provider variables are no longer mandatory in the env 2024-06-11 12:40:00 -03:00
Davidson Gomes
f551242e86 fix: reply message 2024-06-11 11:07:49 -03:00
Davidson Gomes
31258a9b85 feat: Organization configuration and logo in chatwoot bot contact 2024-06-11 10:09:04 -03:00
Davidson Gomes
a8937bd8b1 fix: get message id for typebot 2024-06-10 18:32:05 -03:00