fix: adjusts in returns in endpoints chatwoot and webhook

This commit is contained in:
Davidson Gomes
2023-07-17 11:33:08 -03:00
parent 69353892d9
commit 8a14141021
3 changed files with 35 additions and 17 deletions

View File

@@ -18,9 +18,17 @@ export class WebhookService {
public async find(instance: InstanceDto): Promise<WebhookDto> {
try {
this.logger.verbose('find webhook: ' + instance.instanceName);
return await this.waMonitor.waInstances[instance.instanceName].findWebhook();
const result = await this.waMonitor.waInstances[
instance.instanceName
].findWebhook();
if (Object.keys(result).length === 0) {
throw new Error('Webhook not found');
}
return result;
} catch (error) {
return { enabled: null, url: '' };
return { enabled: false, url: '', events: [], webhook_by_events: false };
}
}
}