diff options
author | Andrés Manelli <andresmanelli@gmail.com> | 2017-08-29 14:41:11 -0300 |
---|---|---|
committer | Andrés Manelli <andresmanelli@gmail.com> | 2017-08-30 00:56:09 -0300 |
commit | f566022aa4cdddf20dd040c8fdc42b83f2cc340e (patch) | |
tree | 9ccbb322cc9c32f988071cddaa89e6f803987000 /server | |
parent | ddc21046b9385ac5ce5bbb9a773484fcd056d10c (diff) | |
download | wekan-f566022aa4cdddf20dd040c8fdc42b83f2cc340e.tar.gz wekan-f566022aa4cdddf20dd040c8fdc42b83f2cc340e.tar.bz2 wekan-f566022aa4cdddf20dd040c8fdc42b83f2cc340e.zip |
Add activity subscription to integrations. Add API for integrations. Allow multiple integrations per board
Diffstat (limited to 'server')
-rw-r--r-- | server/notifications/outgoing.js | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/server/notifications/outgoing.js b/server/notifications/outgoing.js index c227366e..a4f24f92 100644 --- a/server/notifications/outgoing.js +++ b/server/notifications/outgoing.js @@ -9,8 +9,8 @@ const postCatchError = Meteor.wrapAsync((url, options, resolve) => { }); Meteor.methods({ - outgoingWebhooks(integration, description, params) { - check(integration, Object); + outgoingWebhooks(integrations, description, params) { + check(integrations, Array); check(description, String); check(params, Object); @@ -19,7 +19,7 @@ Meteor.methods({ if (quoteParams[key]) quoteParams[key] = `"${params[key]}"`; }); - const user = Users.findOne(integration.userId); + const user = Users.findOne(params.userId); const text = `${params.user} ${TAPi18n.__(description, quoteParams, user.getLanguage())}\n${params.url}`; if (text.length === 0) return; @@ -41,12 +41,14 @@ Meteor.methods({ data: value, }; - const response = postCatchError(integration.url, options); + integrations.forEach((integration) => { + const response = postCatchError(integration.url, options); - if (response && response.statusCode && response.statusCode === 200) { - return true; // eslint-disable-line consistent-return - } else { - throw new Meteor.Error('error-invalid-webhook-response'); - } + if (response && response.statusCode && response.statusCode === 200) { + return true; // eslint-disable-line consistent-return + } else { + throw new Meteor.Error('error-invalid-webhook-response'); + } + }); }, }); |