diff --git a/src/config/env.config.ts b/src/config/env.config.ts index 36f9ff9c..45e04cc5 100644 --- a/src/config/env.config.ts +++ b/src/config/env.config.ts @@ -69,6 +69,7 @@ export type DBOptions = { MESSAGE_UPDATE: boolean; CONTACTS: boolean; CHATS: boolean; + LOGS: boolean; }; export type StoreConf = { @@ -172,6 +173,7 @@ export class ConfigService { MESSAGE_UPDATE: process.env?.DATABASE_SAVE_MESSAGE_UPDATE === 'true', CONTACTS: process.env?.DATABASE_SAVE_DATA_CONTACTS === 'true', CHATS: process.env?.DATABASE_SAVE_DATA_CHATS === 'true', + LOGS: process.env?.DATABASE_SAVE_LOGS === 'true', }, }, REDIS: { diff --git a/src/repository/repository.service.ts b/src/repository/repository.service.ts index 9633cb3d..06ae0127 100644 --- a/src/repository/repository.service.ts +++ b/src/repository/repository.service.ts @@ -45,7 +45,7 @@ import { Prisma, PrismaClient, Webhook } from '@prisma/client'; import { WebhookEvents } from '../whatsapp/dto/webhook.dto'; import { BadRequestException, NotFoundException } from '../exceptions'; import { Logger } from '../config/logger.config'; -import { ConfigService } from '../config/env.config'; +import { ConfigService, Database } from '../config/env.config'; type CreateLogs = { context: string; @@ -128,6 +128,9 @@ export class Repository extends PrismaClient { } public async createLogs(instance: string, logs: CreateLogs) { + if (!this.configService.get('DATABASE').DB_OPTIONS?.LOGS) { + return; + } return await this.activityLogs.create({ data: { ...logs,