Fix linting

This commit is contained in:
niclas.koegl 2023-03-21 19:45:44 +01:00
parent 776a482a1d
commit d9558833fc
No known key found for this signature in database
GPG Key ID: 5C28FC26802C157A
3 changed files with 26 additions and 26 deletions

View File

@ -2,14 +2,14 @@ const NotificationProvider = require("./notification-provider");
const axios = require("axios"); const axios = require("axios");
const { UP, DOWN } = require("../../src/util"); const { UP, DOWN } = require("../../src/util");
const opsgenieAlertsUrlEU = "https://api.eu.opsgenie.com/v2/alerts" const opsgenieAlertsUrlEU = "https://api.eu.opsgenie.com/v2/alerts";
const opsgenieAlertsUrlUS = "https://api.opsgenie.com/v2/alerts" const opsgenieAlertsUrlUS = "https://api.opsgenie.com/v2/alerts";
let okMsg = "Sent Successfully."; let okMsg = "Sent Successfully.";
class Opsgenie extends NotificationProvider { class Opsgenie extends NotificationProvider {
name = "Opsgenie"; name = "Opsgenie";
/** /**
* @inheritdoc * @inheritdoc
*/ */
@ -17,7 +17,7 @@ class Opsgenie extends NotificationProvider {
let opsgenieAlertsUrl; let opsgenieAlertsUrl;
let priority = (notification.opsgeniePriority == "") ? 3 : notification.opsgeniePriority; let priority = (notification.opsgeniePriority == "") ? 3 : notification.opsgeniePriority;
const textMsg = "Uptime Kuma Alert"; const textMsg = "Uptime Kuma Alert";
try { try {
switch (notification.opsgenieRegion) { switch (notification.opsgenieRegion) {
case "US": case "US":
@ -28,7 +28,7 @@ class Opsgenie extends NotificationProvider {
break; break;
default: default:
opsgenieAlertsUrl = opsgenieAlertsUrlUS; opsgenieAlertsUrl = opsgenieAlertsUrlUS;
}; }
if (heartbeatJSON == null) { if (heartbeatJSON == null) {
let notificationTestAlias = "uptime-kuma-notification-test"; let notificationTestAlias = "uptime-kuma-notification-test";
@ -38,12 +38,12 @@ class Opsgenie extends NotificationProvider {
"source": "Uptime Kuma", "source": "Uptime Kuma",
"priority": "P5" "priority": "P5"
}; };
return this.post(notification, opsgenieAlertsUrl, data) return this.post(notification, opsgenieAlertsUrl, data);
}; }
if (heartbeatJSON.status === DOWN) { if (heartbeatJSON.status === DOWN) {
let data = { let data = {
"message": monitorJSON ? textMsg + `: ${monitorJSON.name}` : textMsg, "message": monitorJSON ? textMsg + `: ${monitorJSON.name}` : textMsg,
"alias": monitorJSON.name, "alias": monitorJSON.name,
"description": msg, "description": msg,
@ -51,24 +51,24 @@ class Opsgenie extends NotificationProvider {
"priority": `P${priority}` "priority": `P${priority}`
}; };
return this.post(notification, opsgenieAlertsUrl, data) return this.post(notification, opsgenieAlertsUrl, data);
}; }
if (heartbeatJSON.status === UP) { if (heartbeatJSON.status === UP) {
let opsgenieAlertsCloseUrl = `${opsgenieAlertsUrl}/${encodeURIComponent(monitorJSON.name)}/close?identifierType=alias`; let opsgenieAlertsCloseUrl = `${opsgenieAlertsUrl}/${encodeURIComponent(monitorJSON.name)}/close?identifierType=alias`;
let data = { let data = {
"source": "Uptime Kuma", "source": "Uptime Kuma",
}; };
return this.post(notification, opsgenieAlertsCloseUrl, data) return this.post(notification, opsgenieAlertsCloseUrl, data);
}; }
} catch (error) { } catch (error) {
this.throwGeneralAxiosError(error); this.throwGeneralAxiosError(error);
} }
} }
/** /**
* *
* @param {BeanModel} notification * @param {BeanModel} notification
* @param {string} url Request url * @param {string} url Request url
* @param {Object} data Request body * @param {Object} data Request body
@ -85,12 +85,12 @@ class Opsgenie extends NotificationProvider {
let res = await axios.post(url, data, config); let res = await axios.post(url, data, config);
if (res.status == null) { if (res.status == null) {
return "Opsgenie notification failed with invalid response!"; return "Opsgenie notification failed with invalid response!";
}; }
if (res.status < 200 || res.status >= 300) { if (res.status < 200 || res.status >= 300) {
return `Opsgenie notification failed with status code ${res.status}`; return `Opsgenie notification failed with status code ${res.status}`;
}; }
return okMsg return okMsg;
} }
} }

View File

@ -84,7 +84,7 @@ class Notification {
new Ntfy(), new Ntfy(),
new Octopush(), new Octopush(),
new OneBot(), new OneBot(),
new Opsgenie(), new Opsgenie(),
new PagerDuty(), new PagerDuty(),
new PagerTree(), new PagerTree(),
new PromoSMS(), new PromoSMS(),

View File

@ -18,12 +18,12 @@
<label for="opsgenie-priority" class="form-label">{{ $t("Priority") }}</label> <label for="opsgenie-priority" class="form-label">{{ $t("Priority") }}</label>
<input id="opsgenie-priority" v-model="$parent.notification.opsgeniePriority" type="number" class="form-control" min="1" max="5" step="1"> <input id="opsgenie-priority" v-model="$parent.notification.opsgeniePriority" type="number" class="form-control" min="1" max="5" step="1">
</div> </div>
<div class="form-text"> <div class="form-text">
<span style="color: red;"><sup>*</sup></span>{{ $t("Required") }} <span style="color: red;"><sup>*</sup></span>{{ $t("Required") }}
<i18n-t tag="p" keypath="aboutWebhooks" style="margin-top: 8px;"> <i18n-t tag="p" keypath="aboutWebhooks" style="margin-top: 8px;">
<a href="https://docs.opsgenie.com/docs/alert-api" target="_blank">https://docs.opsgenie.com/docs/alert-api</a> <a href="https://docs.opsgenie.com/docs/alert-api" target="_blank">https://docs.opsgenie.com/docs/alert-api</a>
</i18n-t> </i18n-t>
</div> </div>
</template> </template>
<script> <script>