feat: Added configuration of events by webhook of instances

This commit is contained in:
Davidson Gomes
2023-06-12 14:40:26 -03:00
parent 0f360d34e8
commit fc30bb9852
8 changed files with 81 additions and 9 deletions

View File

@@ -22,12 +22,10 @@ export class InstanceController {
private readonly logger = new Logger(InstanceController.name);
public async createInstance({ instanceName, webhook }: InstanceDto) {
//verifica se modo da instancia é container
public async createInstance({ instanceName, webhook, events }: InstanceDto) {
const mode = this.configService.get<Auth>('AUTHENTICATION').INSTANCE.MODE;
if (mode === 'container') {
//verifica se ja existe uma instancia criada com qualquer nome
if (Object.keys(this.waMonitor.waInstances).length > 0) {
throw new BadRequestException([
'Instance already created',
@@ -50,7 +48,7 @@ export class InstanceController {
if (webhook) {
try {
this.webhookService.create(instance, { enabled: true, url: webhook });
this.webhookService.create(instance, { enabled: true, url: webhook, events });
} catch (error) {
this.logger.log(error);
}