(id, data)
| 49 | } |
| 50 | |
| 51 | function update(id, data) { |
| 52 | return db.Alert.update(data, { |
| 53 | where: { |
| 54 | id, |
| 55 | }, |
| 56 | }) |
| 57 | .then(() => { |
| 58 | return findById(id); |
| 59 | }) |
| 60 | .then(async (alert) => { |
| 61 | if (data.alertIntegrations) { |
| 62 | data.alertIntegrations.forEach((ai) => { |
| 63 | const foundIntegration = alert.AlertIntegrations.find((alertIntegration) => { |
| 64 | return alertIntegration.id === ai.id; |
| 65 | }); |
| 66 | |
| 67 | if (foundIntegration) { |
| 68 | db.AlertIntegration.update({ |
| 69 | enabled: ai.enabled, |
| 70 | }, { |
| 71 | where: { |
| 72 | id: foundIntegration.id, |
| 73 | }, |
| 74 | }); |
| 75 | } else { |
| 76 | db.AlertIntegration.create({ |
| 77 | alert_id: alert.id, |
| 78 | integration_id: ai.integration_id, |
| 79 | enabled: ai.enabled, |
| 80 | }); |
| 81 | } |
| 82 | }); |
| 83 | } |
| 84 | return findById(id); |
| 85 | }); |
| 86 | } |
| 87 | |
| 88 | function remove(id) { |
| 89 | return db.Alert.destroy({ |
no test coverage detected