fix: Adjusted set in webhook to go empty when enabled false

This commit is contained in:
Davidson Gomes
2023-07-07 13:12:51 -03:00
parent 24712c4c2d
commit 27aa0add4e
6 changed files with 20 additions and 15 deletions

View File

@@ -8,9 +8,15 @@ export class WebhookController {
constructor(private readonly webhookService: WebhookService) {}
public async createWebhook(instance: InstanceDto, data: WebhookDto) {
if (!isURL(data.url, { require_tld: false })) {
if (data.enabled && !isURL(data.url, { require_tld: false })) {
throw new BadRequestException('Invalid "url" property');
}
if (!data.enabled) {
data.url = '';
data.events = [];
}
return this.webhookService.create(instance, data);
}