feat: Added verbose logs and format chatwoot service

This commit is contained in:
Davidson Gomes 2023-07-14 14:17:48 -03:00
parent cffb4736ce
commit 6005d33c94

View File

@ -97,12 +97,7 @@ export class InstanceController {
} }
} }
if ( if (!chatwoot_account_id || !chatwoot_token || !chatwoot_url) {
!chatwoot_account_id ||
!chatwoot_token ||
!chatwoot_url ||
!chatwoot_sign_msg
) {
this.logger.verbose('instance created'); this.logger.verbose('instance created');
this.logger.verbose({ this.logger.verbose({
instance: { instance: {
@ -137,10 +132,6 @@ export class InstanceController {
throw new BadRequestException('url is required'); throw new BadRequestException('url is required');
} }
if (!chatwoot_sign_msg) {
throw new BadRequestException('sign_msg is required');
}
const urlServer = this.configService.get<HttpServer>('SERVER').URL; const urlServer = this.configService.get<HttpServer>('SERVER').URL;
try { try {
@ -149,7 +140,7 @@ export class InstanceController {
account_id: chatwoot_account_id, account_id: chatwoot_account_id,
token: chatwoot_token, token: chatwoot_token,
url: chatwoot_url, url: chatwoot_url,
sign_msg: chatwoot_sign_msg, sign_msg: chatwoot_sign_msg || false,
name_inbox: instance.instanceName, name_inbox: instance.instanceName,
}); });
@ -174,7 +165,7 @@ export class InstanceController {
account_id: chatwoot_account_id, account_id: chatwoot_account_id,
token: chatwoot_token, token: chatwoot_token,
url: chatwoot_url, url: chatwoot_url,
sign_msg: chatwoot_sign_msg, sign_msg: chatwoot_sign_msg || false,
name_inbox: instance.instanceName, name_inbox: instance.instanceName,
webhook_url: `${urlServer}/chatwoot/webhook/${instance.instanceName}`, webhook_url: `${urlServer}/chatwoot/webhook/${instance.instanceName}`,
}, },
@ -227,12 +218,7 @@ export class InstanceController {
} }
} }
if ( if (!chatwoot_account_id || !chatwoot_token || !chatwoot_url) {
!chatwoot_account_id ||
!chatwoot_token ||
!chatwoot_url ||
!chatwoot_sign_msg
) {
let getQrcode: wa.QrCode; let getQrcode: wa.QrCode;
if (qrcode) { if (qrcode) {
@ -280,10 +266,6 @@ export class InstanceController {
throw new BadRequestException('url is required'); throw new BadRequestException('url is required');
} }
if (!chatwoot_sign_msg) {
throw new BadRequestException('sign_msg is required');
}
const urlServer = this.configService.get<HttpServer>('SERVER').URL; const urlServer = this.configService.get<HttpServer>('SERVER').URL;
try { try {
@ -292,7 +274,7 @@ export class InstanceController {
account_id: chatwoot_account_id, account_id: chatwoot_account_id,
token: chatwoot_token, token: chatwoot_token,
url: chatwoot_url, url: chatwoot_url,
sign_msg: chatwoot_sign_msg, sign_msg: chatwoot_sign_msg || false,
name_inbox: instance.instanceName, name_inbox: instance.instanceName,
}); });
@ -320,7 +302,7 @@ export class InstanceController {
account_id: chatwoot_account_id, account_id: chatwoot_account_id,
token: chatwoot_token, token: chatwoot_token,
url: chatwoot_url, url: chatwoot_url,
sign_msg: chatwoot_sign_msg, sign_msg: chatwoot_sign_msg || false,
name_inbox: instance.instanceName, name_inbox: instance.instanceName,
webhook_url: `${urlServer}/chatwoot/webhook/${instance.instanceName}`, webhook_url: `${urlServer}/chatwoot/webhook/${instance.instanceName}`,
}, },