mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-05-31 02:42:34 +02:00
Merge branch 'master' into feature/umami-analytics-status-page
This commit is contained in:
commit
62f828af65
8 changed files with 76 additions and 2 deletions
|
@ -42,6 +42,7 @@ class SMTP extends NotificationProvider {
|
|||
// default values in case the user does not want to template
|
||||
let subject = msg;
|
||||
let body = msg;
|
||||
let useHTMLBody = false;
|
||||
if (heartbeatJSON) {
|
||||
body = `${msg}\nTime (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`;
|
||||
}
|
||||
|
@ -50,11 +51,11 @@ class SMTP extends NotificationProvider {
|
|||
// cannot end with whitespace as this often raises spam scores
|
||||
const customSubject = notification.customSubject?.trim() || "";
|
||||
const customBody = notification.customBody?.trim() || "";
|
||||
|
||||
if (customSubject !== "") {
|
||||
subject = await this.renderTemplate(customSubject, msg, monitorJSON, heartbeatJSON);
|
||||
}
|
||||
if (customBody !== "") {
|
||||
useHTMLBody = notification.htmlBody || false;
|
||||
body = await this.renderTemplate(customBody, msg, monitorJSON, heartbeatJSON);
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +68,8 @@ class SMTP extends NotificationProvider {
|
|||
bcc: notification.smtpBCC,
|
||||
to: notification.smtpTo,
|
||||
subject: subject,
|
||||
text: body,
|
||||
// If the email body is custom, and the user wants it, set the email body as HTML
|
||||
[useHTMLBody ? "html" : "text"]: body
|
||||
});
|
||||
|
||||
return okMsg;
|
||||
|
|
37
server/notification-providers/spugpush.js
Normal file
37
server/notification-providers/spugpush.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
const NotificationProvider = require("./notification-provider");
|
||||
const axios = require("axios");
|
||||
const { DOWN, UP } = require("../../src/util");
|
||||
|
||||
class SpugPush extends NotificationProvider {
|
||||
|
||||
name = "SpugPush";
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
||||
let okMsg = "Sent Successfully.";
|
||||
try {
|
||||
let formData = {
|
||||
msg
|
||||
};
|
||||
const apiUrl = `https://push.spug.cc/send/${notification.templateKey}`;
|
||||
if (heartbeatJSON == null) {
|
||||
formData.title = "Uptime Kuma Message";
|
||||
} else if (heartbeatJSON["status"] === UP) {
|
||||
formData.title = `UptimeKuma 「${monitorJSON["name"]}」 is Up`;
|
||||
formData.msg = `[✅ Up] ${heartbeatJSON["msg"]}`;
|
||||
} else if (heartbeatJSON["status"] === DOWN) {
|
||||
formData.title = `UptimeKuma 「${monitorJSON["name"]}」 is Down`;
|
||||
formData.msg = `[🔴 Down] ${heartbeatJSON["msg"]}`;
|
||||
}
|
||||
|
||||
await axios.post(apiUrl, formData);
|
||||
return okMsg;
|
||||
} catch (error) {
|
||||
this.throwGeneralAxiosError(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = SpugPush;
|
|
@ -75,6 +75,7 @@ const Wpush = require("./notification-providers/wpush");
|
|||
const SendGrid = require("./notification-providers/send-grid");
|
||||
const YZJ = require("./notification-providers/yzj");
|
||||
const SMSPlanet = require("./notification-providers/sms-planet");
|
||||
const SpugPush = require("./notification-providers/spugpush");
|
||||
|
||||
class Notification {
|
||||
|
||||
|
@ -167,6 +168,7 @@ class Notification {
|
|||
new SendGrid(),
|
||||
new YZJ(),
|
||||
new SMSPlanet(),
|
||||
new SpugPush(),
|
||||
];
|
||||
for (let item of list) {
|
||||
if (! item.name) {
|
||||
|
|
|
@ -185,6 +185,7 @@ export default {
|
|||
"WeCom": "WeCom (企业微信群机器人)",
|
||||
"ServerChan": "ServerChan (Server酱)",
|
||||
"PushPlus": "PushPlus (推送加)",
|
||||
"SpugPush": "SpugPush(Spug推送助手)",
|
||||
"smsc": "SMSC",
|
||||
"WPush": "WPush(wpush.cn)",
|
||||
"YZJ": "YZJ (云之家自定义机器人)",
|
||||
|
|
|
@ -79,6 +79,15 @@
|
|||
<div class="form-text">{{ $t("leave blank for default body") }}</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<div class="form-check">
|
||||
<input id="use-html-body" v-model="$parent.notification.htmlBody" class="form-check-input" type="checkbox" value="">
|
||||
<label class="form-check-label" for="use-html-body">
|
||||
{{ $t("Use HTML for custom E-mail body") }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ToggleSection :heading="$t('smtpDkimSettings')">
|
||||
<i18n-t tag="div" keypath="smtpDkimDesc" class="form-text mb-3">
|
||||
<a href="https://nodemailer.com/dkim/" target="_blank">{{ $t("documentation") }}</a>
|
||||
|
|
19
src/components/notifications/SpugPush.vue
Normal file
19
src/components/notifications/SpugPush.vue
Normal file
|
@ -0,0 +1,19 @@
|
|||
<template>
|
||||
<div class="mb-3">
|
||||
<label for="spugpush-templateKey" class="form-label">{{ $t("SpugPush Template Code") }}</label>
|
||||
<HiddenInput id="spugpush-templateKey" v-model="$parent.notification.templateKey" :required="true" autocomplete="new-password"></HiddenInput>
|
||||
</div>
|
||||
<i18n-t tag="p" keypath="More info on:" style="margin-top: 8px;">
|
||||
<a href="https://push.spug.cc/guide/plugin/kuma" rel="noopener noreferrer" target="_blank">https://push.spug.cc</a>
|
||||
</i18n-t>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import HiddenInput from "../HiddenInput.vue";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
HiddenInput,
|
||||
},
|
||||
};
|
||||
</script>
|
|
@ -64,6 +64,7 @@ import WeCom from "./WeCom.vue";
|
|||
import GoAlert from "./GoAlert.vue";
|
||||
import ZohoCliq from "./ZohoCliq.vue";
|
||||
import Splunk from "./Splunk.vue";
|
||||
import SpugPush from "./SpugPush.vue";
|
||||
import SevenIO from "./SevenIO.vue";
|
||||
import Whapi from "./Whapi.vue";
|
||||
import WAHA from "./WAHA.vue";
|
||||
|
@ -140,6 +141,7 @@ const NotificationFormList = {
|
|||
"threema": Threema,
|
||||
"twilio": Twilio,
|
||||
"Splunk": Splunk,
|
||||
"SpugPush": SpugPush,
|
||||
"webhook": Webhook,
|
||||
"WeCom": WeCom,
|
||||
"GoAlert": GoAlert,
|
||||
|
|
|
@ -517,6 +517,7 @@
|
|||
"Clone": "Clone",
|
||||
"cloneOf": "Clone of {0}",
|
||||
"smtp": "Email (SMTP)",
|
||||
"Use HTML for custom E-mail body": "Use HTML for custom E-mail body",
|
||||
"secureOptionNone": "None / STARTTLS (25, 587)",
|
||||
"secureOptionTLS": "TLS (465)",
|
||||
"Ignore TLS Error": "Ignore TLS Error",
|
||||
|
@ -798,6 +799,7 @@
|
|||
"PushDeer Server": "PushDeer Server",
|
||||
"pushDeerServerDescription": "Leave blank to use the official server",
|
||||
"PushDeer Key": "PushDeer Key",
|
||||
"SpugPush Template Code": "Template Code",
|
||||
"wayToGetClickSendSMSToken": "You can get API Username and API Key from {0} .",
|
||||
"Custom Monitor Type": "Custom Monitor Type",
|
||||
"Google Analytics ID": "Google Analytics ID",
|
||||
|
|
Loading…
Add table
Reference in a new issue