mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-22 20:12:02 -06:00
Remove template model and related functionality (prisma/postgresql-schema.prisma, src/api/services/template.service.ts)
This commit removes the Template model, including its related functionality, from the project. The template table has been removed from the database schema, and all related functions and methods in the template service have been deleted. This change was made because the project now uses the persistence of the meta, eliminating the need for a separate template model. Please note that this change may affect other parts of the application that rely on the Template model. Ensure that all necessary adjustments have been made before merging this commit.
This commit is contained in:
parent
ca3dadfb35
commit
c782305456
@ -0,0 +1,11 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the `Template` table. If the table is not empty, all the data it contains will be lost.
|
||||
|
||||
*/
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Template" DROP CONSTRAINT "Template_instanceId_fkey";
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE "Template";
|
@ -75,7 +75,6 @@ model Instance {
|
||||
MessageUpdate MessageUpdate[]
|
||||
TypebotSession TypebotSession[]
|
||||
TypebotSetting TypebotSetting?
|
||||
Template Template[]
|
||||
}
|
||||
|
||||
model Session {
|
||||
@ -306,14 +305,3 @@ model TypebotSetting {
|
||||
Instance Instance @relation(fields: [instanceId], references: [id], onDelete: Cascade)
|
||||
instanceId String @unique
|
||||
}
|
||||
|
||||
model Template {
|
||||
id String @id @default(cuid())
|
||||
name String @db.VarChar(255)
|
||||
language String @db.VarChar(255)
|
||||
templateId String @unique @db.VarChar(255)
|
||||
createdAt DateTime? @default(now()) @db.Timestamp
|
||||
updatedAt DateTime @updatedAt @db.Timestamp
|
||||
Instance Instance @relation(fields: [instanceId], references: [id], onDelete: Cascade)
|
||||
instanceId String
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { Template } from '@prisma/client';
|
||||
import axios from 'axios';
|
||||
|
||||
import { ConfigService, WaBusiness } from '../../config/env.config';
|
||||
@ -39,7 +38,7 @@ export class TemplateService {
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async create(instance: InstanceDto, data: TemplateDto): Promise<Template> {
|
||||
public async create(instance: InstanceDto, data: TemplateDto) {
|
||||
try {
|
||||
const getInstance = await this.waMonitor.waInstances[instance.instanceName].instance;
|
||||
|
||||
@ -61,21 +60,10 @@ export class TemplateService {
|
||||
const response = await this.requestTemplate(postData, 'POST');
|
||||
|
||||
if (!response) {
|
||||
throw new Error('Error to create template');
|
||||
return response;
|
||||
}
|
||||
|
||||
console.log(response);
|
||||
|
||||
const template = await this.prismaRepository.template.create({
|
||||
data: {
|
||||
instanceId: getInstance.id,
|
||||
templateId: response.id,
|
||||
name: data.name,
|
||||
language: data.language,
|
||||
},
|
||||
});
|
||||
|
||||
return template;
|
||||
return response;
|
||||
} catch (error) {
|
||||
this.logger.error(error);
|
||||
throw new Error('Error to create template');
|
||||
@ -94,13 +82,10 @@ export class TemplateService {
|
||||
} else if (method === 'POST') {
|
||||
const result = await axios.post(urlServer, data, { headers });
|
||||
return result.data;
|
||||
} else if (method === 'DELETE') {
|
||||
const result = await axios.delete(urlServer + '/' + data, { headers });
|
||||
return result.data;
|
||||
}
|
||||
} catch (e) {
|
||||
this.logger.error(e.response.data);
|
||||
return null;
|
||||
return e.response.data.error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user