From 4cdc8f344bf83be9c1f206b91f6d9a58faa1f8a3 Mon Sep 17 00:00:00 2001 From: Humberto Evans Date: Tue, 13 Feb 2024 16:54:52 -0800 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Frank Elsinga --- server/notification-providers/heii-oncall.js | 15 ++++----------- src/components/notifications/HeiiOnCall.vue | 2 +- src/lang/en.json | 2 +- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/server/notification-providers/heii-oncall.js b/server/notification-providers/heii-oncall.js index f31bc4acf..75ebf6140 100644 --- a/server/notification-providers/heii-oncall.js +++ b/server/notification-providers/heii-oncall.js @@ -3,9 +3,6 @@ const { setting } = require("../util-server"); const NotificationProvider = require("./notification-provider"); const axios = require("axios"); - -const heiiOnCallBaseUrl = "https://heiioncall.com"; - class HeiiOnCall extends NotificationProvider { name = "HeiiOnCall"; @@ -13,28 +10,24 @@ class HeiiOnCall extends NotificationProvider { * @inheritdoc */ async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { - // Payload to Heii On-Call is the entire heartbat JSON - const payload = heartbeatJSON ? heartbeatJSON : {}; + const payload = heartbeatJSON || {}; - // If we can, add url back to monitor to payload const baseURL = await setting("primaryBaseURL"); if (baseURL && monitorJSON) { payload["url"] = baseURL + getMonitorRelativeURL(monitorJSON.id); } if (!heartbeatJSON) { - // No heartbeatJSON. Could be test button, but not necessarily. Just pull msg into payload. + // Testing or general notification like certificate expiry payload["msg"] = msg; return this.postNotification(notification, "alert", payload); } if (heartbeatJSON.status === DOWN) { - // Monitor is DOWN, alert on Heii On-Call return this.postNotification(notification, "alert", payload); } if (heartbeatJSON.status === UP) { - // Monitor is UP, resolve on Heii On-Call return this.postNotification(notification, "resolve", payload); } } @@ -58,7 +51,7 @@ class HeiiOnCall extends NotificationProvider { // Post to Heii On-Call Trigger https://heiioncall.com/docs#manual-triggers try { await axios.post( - `${heiiOnCallBaseUrl}/triggers/${notification.heiiOnCallTriggerId}/${action}`, + `https://heiioncall.com/triggers/${notification.heiiOnCallTriggerId}/${action}`, payload, config ); @@ -66,7 +59,7 @@ class HeiiOnCall extends NotificationProvider { this.throwGeneralAxiosError(error); } - return "Heii On-Call post sent successfully."; + return "Sent Successfully"; } } diff --git a/src/components/notifications/HeiiOnCall.vue b/src/components/notifications/HeiiOnCall.vue index 85fb91b67..54c991344 100644 --- a/src/components/notifications/HeiiOnCall.vue +++ b/src/components/notifications/HeiiOnCall.vue @@ -19,7 +19,7 @@ diff --git a/src/lang/en.json b/src/lang/en.json index 9fa64d8da..e95dc56c2 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -885,5 +885,5 @@ "Browser Screenshot": "Browser Screenshot", "What is a Remote Browser?": "What is a Remote Browser?", "Trigger ID": "Trigger ID", - "wayToGetHeiiOnCallDetails": "To get a Heii On-Call Tigger ID and Api Token visit: {0}" + "wayToGetHeiiOnCallDetails": "How to get the Tigger ID and API Keys is explained in the {documentation}" }