mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-26 07:07:45 -06:00
feat: Show webhook_url for chatwoot
This commit is contained in:
@@ -5,11 +5,15 @@ import { ChatwootDto } from '../dto/chatwoot.dto';
|
||||
import { ChatwootService } from '../services/chatwoot.service';
|
||||
import { Logger } from '../../config/logger.config';
|
||||
import { waMonitor } from '../whatsapp.module';
|
||||
import { ConfigService, HttpServer } from '../../config/env.config';
|
||||
|
||||
const logger = new Logger('ChatwootController');
|
||||
|
||||
export class ChatwootController {
|
||||
constructor(private readonly chatwootService: ChatwootService) {}
|
||||
constructor(
|
||||
private readonly chatwootService: ChatwootService,
|
||||
private readonly configService: ConfigService,
|
||||
) {}
|
||||
|
||||
public async createChatwoot(instance: InstanceDto, data: ChatwootDto) {
|
||||
logger.verbose(
|
||||
@@ -46,9 +50,11 @@ export class ChatwootController {
|
||||
|
||||
const result = this.chatwootService.create(instance, data);
|
||||
|
||||
const urlServer = this.configService.get<HttpServer>('SERVER').URL;
|
||||
|
||||
const response = {
|
||||
...result,
|
||||
webhook_url: `/chatwoot/webhook/${instance.instanceName}`,
|
||||
webhook_url: `${urlServer}/chatwoot/webhook/${instance.instanceName}`,
|
||||
};
|
||||
|
||||
return response;
|
||||
@@ -56,11 +62,13 @@ export class ChatwootController {
|
||||
|
||||
public async findChatwoot(instance: InstanceDto) {
|
||||
logger.verbose('requested findChatwoot from ' + instance.instanceName + ' instance');
|
||||
const result = this.chatwootService.find(instance);
|
||||
const result = await this.chatwootService.find(instance);
|
||||
|
||||
const urlServer = this.configService.get<HttpServer>('SERVER').URL;
|
||||
|
||||
const response = {
|
||||
...result,
|
||||
webhook_url: `/chatwoot/webhook/${instance.instanceName}`,
|
||||
webhook_url: `${urlServer}/chatwoot/webhook/${instance.instanceName}`,
|
||||
};
|
||||
|
||||
return response;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { delay } from '@whiskeysockets/baileys';
|
||||
import EventEmitter2 from 'eventemitter2';
|
||||
import { Auth, ConfigService } from '../../config/env.config';
|
||||
import { Auth, ConfigService, HttpServer } from '../../config/env.config';
|
||||
import { BadRequestException, InternalServerErrorException } from '../../exceptions';
|
||||
import { InstanceDto } from '../dto/instance.dto';
|
||||
import { RepositoryBroker } from '../repository/repository.manager';
|
||||
@@ -154,6 +154,8 @@ export class InstanceController {
|
||||
this.logger.log(error);
|
||||
}
|
||||
|
||||
const urlServer = this.configService.get<HttpServer>('SERVER').URL;
|
||||
|
||||
return {
|
||||
instance: {
|
||||
instanceName: instance.instanceName,
|
||||
@@ -167,7 +169,7 @@ export class InstanceController {
|
||||
url: chatwoot_url,
|
||||
sign_msg: chatwoot_sign_msg,
|
||||
name_inbox: instance.instanceName,
|
||||
webhook_url: `/chatwoot/webhook/${instance.instanceName}`,
|
||||
webhook_url: `${urlServer}/chatwoot/webhook/${instance.instanceName}`,
|
||||
},
|
||||
};
|
||||
} else {
|
||||
@@ -288,6 +290,8 @@ export class InstanceController {
|
||||
this.logger.log(error);
|
||||
}
|
||||
|
||||
const urlServer = this.configService.get<HttpServer>('SERVER').URL;
|
||||
|
||||
return {
|
||||
instance: {
|
||||
instanceName: instance.instanceName,
|
||||
@@ -301,7 +305,7 @@ export class InstanceController {
|
||||
url: chatwoot_url,
|
||||
sign_msg: chatwoot_sign_msg,
|
||||
name_inbox: instance.instanceName,
|
||||
webhook_url: `/chatwoot/webhook/${instance.instanceName}`,
|
||||
webhook_url: `${urlServer}/chatwoot/webhook/${instance.instanceName}`,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user