diff --git a/test/api/v3/integration/webhook/PUT-user_update_webhook.test.js b/test/api/v3/integration/webhook/PUT-user_update_webhook.test.js index 0f00e238e9..571e084742 100644 --- a/test/api/v3/integration/webhook/PUT-user_update_webhook.test.js +++ b/test/api/v3/integration/webhook/PUT-user_update_webhook.test.js @@ -63,6 +63,26 @@ describe('PUT /user/webhook/:id', () => { expect(webhook.options).to.eql(options); }); + it('updates a webhook with empty label', async () => { + const url = 'http://a-new-url.com'; + const type = 'groupChatReceived'; + const label = ''; + const options = { groupId: generateUUID() }; + + await user.put(`/user/webhook/${webhookToUpdate.id}`, { + url, type, options, label, + }); + + await user.sync(); + + const webhook = user.webhooks.find(hook => webhookToUpdate.id === hook.id); + + expect(webhook.url).to.equal(url); + expect(webhook.label).to.equal(label); + expect(webhook.type).to.equal(type); + expect(webhook.options).to.eql(options); + }); + it('returns the updated webhook', async () => { const url = 'http://a-new-url.com'; const type = 'groupChatReceived'; diff --git a/website/server/controllers/api-v3/webhook.js b/website/server/controllers/api-v3/webhook.js index e85730a792..b7c037eeff 100644 --- a/website/server/controllers/api-v3/webhook.js +++ b/website/server/controllers/api-v3/webhook.js @@ -179,7 +179,8 @@ api.updateWebhook = { webhook.url = url; } - if (label) { + // using this check to allow the setting of empty labels + if (label !== null && label !== undefined) { webhook.label = label; }