feat: Add WxPusher SPT (WxPusher simple push token) notification provider (#7569)

Co-authored-by: wxpusher <foroutmoney@gmail.com>
This commit is contained in:
zjiecode
2026-07-05 06:28:43 -07:00
committed by GitHub
parent b4ce00530e
commit ffa791da8b
6 changed files with 129 additions and 0 deletions
+73
View File
@@ -0,0 +1,73 @@
const NotificationProvider = require("./notification-provider");
const axios = require("axios");
const { DOWN, UP } = require("../../src/util");
class WxPusher extends NotificationProvider {
name = "WxPusher";
// WxPusher's simple-push accepts at most 10 SPTs per request.
static SPT_PER_REQUEST = 10;
/**
* @inheritdoc
*/
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
const okMsg = "Sent Successfully.";
// Accept one or multiple SPTs, comma-separated.
const sptList = String(notification.wxpusherSPT || "")
.split(",")
.map((spt) => spt.trim())
.filter((spt) => spt.length > 0);
try {
if (sptList.length === 0) {
throw new Error("No WxPusher SPT is configured");
}
const summary = this.checkStatus(heartbeatJSON, monitorJSON).slice(0, 100);
const config = this.getAxiosConfigWithProxy({});
// Send in batches so more than 10 SPTs are all delivered, never silently dropped.
for (let i = 0; i < sptList.length; i += WxPusher.SPT_PER_REQUEST) {
const context = {
content: msg,
summary,
contentType: 1,
sptList: sptList.slice(i, i + WxPusher.SPT_PER_REQUEST),
};
const result = await axios.post(
"https://wxpusher.zjiecode.com/api/send/message/simple-push",
context,
config
);
if (result.data.code !== 1000) {
throw result.data.msg;
}
}
return okMsg;
} catch (error) {
this.throwGeneralAxiosError(error);
}
}
/**
* Get the formatted title for message
* @param {?object} heartbeatJSON Heartbeat details (For Up/Down only)
* @param {?object} monitorJSON Monitor details (For Up/Down only)
* @returns {string} Formatted title
*/
checkStatus(heartbeatJSON, monitorJSON) {
let title = "UptimeKuma Message";
if (heartbeatJSON != null && heartbeatJSON["status"] === UP) {
title = "UptimeKuma Monitor Up " + monitorJSON["name"];
}
if (heartbeatJSON != null && heartbeatJSON["status"] === DOWN) {
title = "UptimeKuma Monitor Down " + monitorJSON["name"];
}
return title;
}
}
module.exports = WxPusher;
+2
View File
@@ -82,6 +82,7 @@ const GtxMessaging = require("./notification-providers/gtx-messaging");
const Cellsynt = require("./notification-providers/cellsynt");
const Onesender = require("./notification-providers/onesender");
const Wpush = require("./notification-providers/wpush");
const WxPusher = require("./notification-providers/wxpusher");
const SendGrid = require("./notification-providers/send-grid");
const Brevo = require("./notification-providers/brevo");
const Resend = require("./notification-providers/resend");
@@ -193,6 +194,7 @@ class Notification {
new GtxMessaging(),
new Cellsynt(),
new Wpush(),
new WxPusher(),
new Brevo(),
new Resend(),
new YZJ(),
+1
View File
@@ -335,6 +335,7 @@ export default {
smsc: "SMSC",
smsir: "SMS.IR",
WPush: "WPush(wpush.cn)",
WxPusher: "WxPusher SPT Push (WxPusher极简推送)",
YZJ: "YZJ (云之家自定义机器人)",
SMSPlanet: "SMSPlanet.pl",
VK: "VK",
+48
View File
@@ -0,0 +1,48 @@
<template>
<div class="mb-3">
<label for="wxpusher-spt" class="form-label">WxPusher SPT</label>
<HiddenInput
id="wxpusher-spt"
v-model="$parent.notification.wxpusherSPT"
:required="true"
autocomplete="new-password"
placeholder="SPT_xxxxxxxxxxxx"
></HiddenInput>
<div class="form-text">
<i18n-t tag="p" keypath="wxPusherSptDescription">
<template #download>
<a
href="https://wxpusher.zjiecode.com/download/?utm_source=uptime-kuma"
target="_blank"
rel="noopener noreferrer"
>
{{ $t("wxPusherDownloadApp") }}
</a>
</template>
<template #docs>
<a
href="https://wxpusher.zjiecode.com/docs/?utm_source=uptime-kuma#/?id=spt"
target="_blank"
rel="noopener noreferrer"
>
{{ $t("wxPusherDocs") }}
</a>
</template>
</i18n-t>
<img
src="https://wxpusher.zjiecode.com/api/qrcode/RwjGLMOPTYp35zSYQr0HxbCPrV9eU0wKVBXU1D5VVtya0cQXEJWPjqBdW3gKLifS.jpg"
alt="WxPusher SPT QR code"
style="width: 160px; height: 160px; margin-top: 8px; display: block"
/>
</div>
</div>
</template>
<script>
import HiddenInput from "../HiddenInput.vue";
export default {
components: {
HiddenInput,
},
};
</script>
+2
View File
@@ -81,6 +81,7 @@ import Whatsapp360messenger from "./360messenger.vue";
import Evolution from "./Evolution.vue";
import Cellsynt from "./Cellsynt.vue";
import WPush from "./WPush.vue";
import WxPusher from "./WxPusher.vue";
import SIGNL4 from "./SIGNL4.vue";
import SendGrid from "./SendGrid.vue";
import Brevo from "./Brevo.vue";
@@ -184,6 +185,7 @@ const NotificationFormList = {
gtxmessaging: GtxMessaging,
Cellsynt: Cellsynt,
WPush: WPush,
WxPusher: WxPusher,
SendGrid: SendGrid,
Brevo: Brevo,
Resend: Resend,
+3
View File
@@ -973,6 +973,9 @@
"PushDeer Server": "PushDeer Server",
"pushDeerServerDescription": "Leave blank to use the official server",
"PushDeer Key": "PushDeer Key",
"wxPusherSptDescription": "WxPusher Simple Push (SPT) delivers through the standalone WxPusher app across 6 platforms — Android, iOS, HarmonyOS, Windows, macOS and Linux ({download}). Scan the QR code below to get your SPT and you are ready to send. Separate multiple SPTs with a comma (,) — see the {docs} for more.",
"wxPusherDownloadApp": "download the app",
"wxPusherDocs": "official guide",
"SpugPush Template Code": "Template Code",
"wayToGetClickSendSMSToken": "You can get API Username and API Key from {here}.",
"wayToGetEgoSMSToken": "You can get your EgoSMS API username and password from {here}.",