Skip to content

Commit

Permalink
fix: save-logs
Browse files Browse the repository at this point in the history
  • Loading branch information
jrclber committed May 24, 2024
1 parent 1be5af5 commit 82341a7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/config/env.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export type DBOptions = {
MESSAGE_UPDATE: boolean;
CONTACTS: boolean;
CHATS: boolean;
LOGS: boolean;
};

export type StoreConf = {
Expand Down Expand Up @@ -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: {
Expand Down
5 changes: 4 additions & 1 deletion src/repository/repository.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -128,6 +128,9 @@ export class Repository extends PrismaClient {
}

public async createLogs(instance: string, logs: CreateLogs) {
if (!this.configService.get<Database>('DATABASE').DB_OPTIONS?.LOGS) {
return;
}
return await this.activityLogs.create({
data: {
...logs,
Expand Down

0 comments on commit 82341a7

Please sign in to comment.