added chatwoot integration activation

This commit is contained in:
Davidson Gomes
2024-06-06 16:38:43 -03:00
parent 99c8cc0242
commit 1be9c7f95d
10 changed files with 119 additions and 58 deletions

View File

@@ -1,7 +1,7 @@
import { isURL } from 'class-validator';
import { CacheEngine } from '../../../../cache/cacheengine';
import { ConfigService, HttpServer } from '../../../../config/env.config';
import { Chatwoot, ConfigService, HttpServer } from '../../../../config/env.config';
import { Logger } from '../../../../config/logger.config';
import { BadRequestException } from '../../../../exceptions';
import { InstanceDto } from '../../../dto/instance.dto';
@@ -21,6 +21,8 @@ export class ChatwootController {
) {}
public async createChatwoot(instance: InstanceDto, data: ChatwootDto) {
if (!this.configService.get<Chatwoot>('CHATWOOT').ENABLED) throw new BadRequestException('Chatwoot is disabled');
logger.verbose('requested createChatwoot from ' + instance.instanceName + ' instance');
if (data.enabled) {
@@ -76,6 +78,8 @@ export class ChatwootController {
}
public async findChatwoot(instance: InstanceDto) {
if (!this.configService.get<Chatwoot>('CHATWOOT').ENABLED) throw new BadRequestException('Chatwoot is disabled');
logger.verbose('requested findChatwoot from ' + instance.instanceName + ' instance');
const result = await this.chatwootService.find(instance);
@@ -102,6 +106,8 @@ export class ChatwootController {
}
public async receiveWebhook(instance: InstanceDto, data: any) {
if (!this.configService.get<Chatwoot>('CHATWOOT').ENABLED) throw new BadRequestException('Chatwoot is disabled');
logger.verbose('requested receiveWebhook from ' + instance.instanceName + ' instance');
const chatwootCache = new CacheService(new CacheEngine(this.configService, ChatwootService.name).getEngine());