feat: IA send images and Sentry implemented

This commit is contained in:
Davidson Gomes
2024-08-16 11:31:46 -03:00
parent 3ef80bd6c5
commit b921a4d324
15 changed files with 283 additions and 227 deletions

View File

@@ -34,7 +34,7 @@ async function apikey(req: Request, _: Response, next: NextFunction) {
return next();
}
} else {
if (req.originalUrl.includes('/instance/fetchInstances') && db.ENABLED) {
if (req.originalUrl.includes('/instance/fetchInstances') && db.SAVE_DATA.INSTANCE) {
const instanceByKey = await prismaRepository.instance.findFirst({
where: { token: key },
});

View File

@@ -1,13 +1,12 @@
import { InstanceDto } from '@api/dto/instance.dto';
import { cache, waMonitor } from '@api/server.module';
import { CacheConf, configService, Database } from '@config/env.config';
import { CacheConf, configService } from '@config/env.config';
import { BadRequestException, ForbiddenException, InternalServerErrorException, NotFoundException } from '@exceptions';
import { prismaServer } from '@libs/prisma.connect';
import { NextFunction, Request, Response } from 'express';
async function getInstance(instanceName: string) {
try {
const db = configService.get<Database>('DATABASE');
const cacheConf = configService.get<CacheConf>('CACHE');
const exists = !!waMonitor.waInstances[instanceName];
@@ -18,13 +17,9 @@ async function getInstance(instanceName: string) {
return exists || keyExists;
}
if (db.ENABLED) {
const prisma = prismaServer;
const prisma = prismaServer;
return exists || (await prisma.instance.findMany({ where: { name: instanceName } })).length > 0;
}
return false;
return exists || (await prisma.instance.findMany({ where: { name: instanceName } })).length > 0;
} catch (error) {
throw new InternalServerErrorException(error?.toString());
}