Fix Outgoing Webhooks Retrying Not Respecting Enabled Status (#6478)

* When retrying an outgoing integration, verify it's enabled first.

* Fix the auto-merge fail from git, the fix moved up to the correct place
pull/6542/head
Bradley Hilton 9 years ago committed by Rodrigo Nascimento
parent 25ff24a3b5
commit 732feb65ce
  1. 1
      HISTORY.md
  2. 17
      packages/rocketchat-integrations/server/lib/triggerHandler.js

@ -5,6 +5,7 @@
- [NEW] Permission `join-without-join-code` assigned to admins and bots by default (#6139)
- [NEW] Integrations, both incoming and outgoing, now have access to the models. Example: `Users.findOneById(id)` (#6336)
- [FIX] Incoming integrations would break when trying to use the `Store` feature.
- [FIX] Outgoing webhooks which have an error and they're retrying would still retry even if the integration was disabled. (#4835)
## 0.54.2 - 2017-Mar-24

@ -54,6 +54,16 @@ RocketChat.integrations.triggerHandler = new class RocketChatIntegrationHandler
}
}
isTriggerEnabled(trigger) {
for (const trig of Object.values(this.triggers)) {
if (trig[trigger._id]) {
return trig[trigger._id].enabled;
}
}
return false;
}
updateHistory({ historyId, step, integration, event, data, triggerWord, ranPrepareScript, prepareSentMessage, processSentMessage, resultMessage, finished, url, httpCallData, httpError, httpResult, error, errorStack }) {
const history = {
type: 'outgoing-webhook',
@ -532,7 +542,7 @@ RocketChat.integrations.triggerHandler = new class RocketChatIntegrationHandler
logger.outgoing.debug(`Found ${ triggersToExecute.length } to iterate over and see if the match the event.`);
for (const triggerToExecute of triggersToExecute) {
logger.outgoing.debug(`Is ${ triggerToExecute.name } enabled, ${ triggerToExecute.enabled }, and what is the event? ${ triggerToExecute.event }`);
logger.outgoing.debug(`Is "${ triggerToExecute.name }" enabled, ${ triggerToExecute.enabled }, and what is the event? ${ triggerToExecute.event }`);
if (triggerToExecute.enabled === true && triggerToExecute.event === event) {
this.executeTrigger(triggerToExecute, argObject);
}
@ -546,6 +556,11 @@ RocketChat.integrations.triggerHandler = new class RocketChatIntegrationHandler
}
executeTriggerUrl(url, trigger, { event, message, room, owner, user }, theHistoryId, tries = 0) {
if (!this.isTriggerEnabled(trigger)) {
logger.outgoing.warn(`The trigger "${ trigger.name }" is no longer enabled, stopping execution of it at try: ${ tries }`);
return;
}
logger.outgoing.debug(`Starting to execute trigger: ${ trigger.name } (${ trigger._id })`);
let word;

Loading…
Cancel
Save