Disable Failing Webhooks (#11966)

* todo comment

* add failures field to webhooks and sanitize

* implement logic

* use update instead of save

* specify timeout and maximum number of retries

* add tests
This commit is contained in:
Matteo Pagliazzi
2020-03-20 23:26:21 +01:00
committed by GitHub
parent ae7df804cb
commit f8aa756d52
8 changed files with 182 additions and 6 deletions

View File

@@ -63,6 +63,21 @@ describe('PUT /user/webhook/:id', () => {
expect(webhook.options).to.eql(options);
});
it('ignores protected fields', async () => {
const failures = 3;
const lastFailureAt = new Date();
await user.put(`/user/webhook/${webhookToUpdate.id}`, {
failures, lastFailureAt,
});
await user.sync();
const webhook = user.webhooks.find(hook => webhookToUpdate.id === hook.id);
expect(webhook.failures).to.eql(0);
expect(webhook.lastFailureAt).to.eql(undefined);
});
it('updates a webhook with empty label', async () => {
const url = 'http://a-new-url.com';
const type = 'groupChatReceived';