The Issue:
The Instance model in the postgresql-schema.prisma file previously had a Template field that was a single Template object, but this caused issues with the association of multiple templates to a single instance.
The Change:
This commit resolves the issue by changing the Template field to an array of Template objects. This allows for multiple templates to be associated with a single instance.
The Impact:
This change allows for more flexible use of templates in the system and resolves a previous limitation in the association of templates to instances.
Affected Files:
- prisma/postgresql-schema.prisma
- src/api/services/template.service.ts
Note: The migration folder added in the untracked files section is a result of the Prisma schema change and can be safely ignored in this commit message.
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.
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.