mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-09 23:24:07 -08:00
Implement gorush notifications
This commit is contained in:
parent
d4b86dc472
commit
ea43422ccf
42
server/notification-providers/gorush.js
Normal file
42
server/notification-providers/gorush.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
const NotificationProvider = require("./notification-provider");
|
||||
const axios = require("axios");
|
||||
|
||||
class Gorush extends NotificationProvider {
|
||||
|
||||
name = "gorush";
|
||||
|
||||
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
||||
let okMsg = "Sent Successfully.";
|
||||
|
||||
let platformMapping = {
|
||||
"ios": 1,
|
||||
"android": 2,
|
||||
"huawei": 3,
|
||||
};
|
||||
|
||||
try {
|
||||
let data = {
|
||||
"notifications": [
|
||||
{
|
||||
"tokens": [notification.gorushDeviceToken],
|
||||
"platform": platformMapping[notification.gorushPlatform],
|
||||
"message": msg,
|
||||
// Optional
|
||||
"title": notification.gorushTitle,
|
||||
"priority": notification.gorushPriority,
|
||||
"retry": parseInt(notification.gorushRetry) || 0,
|
||||
"topic": notification.gorushTopic,
|
||||
}
|
||||
]
|
||||
};
|
||||
let config = {};
|
||||
|
||||
await axios.post(`${notification.gorushServerURL}/api/push`, data, config);
|
||||
return okMsg;
|
||||
} catch (error) {
|
||||
this.throwGeneralAxiosError(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Gorush;
|
|
@ -27,6 +27,7 @@ const SerwerSMS = require("./notification-providers/serwersms");
|
|||
const Stackfield = require("./notification-providers/stackfield");
|
||||
const WeCom = require("./notification-providers/wecom");
|
||||
const GoogleChat = require("./notification-providers/google-chat");
|
||||
const Gorush = require("./notification-providers/gorush");
|
||||
|
||||
class Notification {
|
||||
|
||||
|
@ -65,7 +66,8 @@ class Notification {
|
|||
new SerwerSMS(),
|
||||
new Stackfield(),
|
||||
new WeCom(),
|
||||
new GoogleChat()
|
||||
new GoogleChat(),
|
||||
new Gorush()
|
||||
];
|
||||
|
||||
for (let item of list) {
|
||||
|
|
51
src/components/notifications/Gorush.vue
Normal file
51
src/components/notifications/Gorush.vue
Normal file
|
@ -0,0 +1,51 @@
|
|||
<template>
|
||||
<div class="mb-3">
|
||||
<label for="gorush-device-token" class="form-label">{{ $t("Device Token") }}</label><span style="color: red;"><sup>*</sup></span>
|
||||
<div class="input-group mb-3">
|
||||
<input id="gorush-device-token" v-model="$parent.notification.gorushDeviceToken" type="text" class="form-control" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="gorush-server-url" class="form-label">{{ $t("Server URL") }}</label><span style="color: red;"><sup>*</sup></span>
|
||||
<div class="input-group mb-3">
|
||||
<input id="gorush-server-url" v-model="$parent.notification.gorushServerURL" type="text" class="form-control" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="gorush-platform" class="form-label">{{ $t("Platform") }}</label><span style="color: red;"><sup>*</sup></span>
|
||||
<select id="gorush-platform" v-model="$parent.notification.gorushPlatform" class="form-select">
|
||||
<option value="ios">{{ $t("iOS") }}</option>
|
||||
<option value="android">{{ $t("Android") }}</option>
|
||||
<option value="huawei">{{ $t("Huawei") }}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="gorush-title" class="form-label">{{ $t("Title") }}</label>
|
||||
<input id="gorush-title" v-model="$parent.notification.gorushTitle" type="text" class="form-control">
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="gorush-priority" class="form-label">{{ $t("Priority") }}</label>
|
||||
<select id="gorush-priority" v-model="$parent.notification.gorushPriority" class="form-select">
|
||||
<option value="normal">{{ $t("Normal") }}</option>
|
||||
<option value="high">{{ $t("High") }}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="gorush-retry" class="form-label">{{ $t("Retry") }}</label>
|
||||
<input id="gorush-retry" v-model="$parent.notification.gorushRetry" type="number" class="form-control">
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="gorush-topic" class="form-label">{{ $t("Topic") }}</label>
|
||||
<input id="gorush-topic" v-model="$parent.notification.gorushTopic" type="text" class="form-control">
|
||||
</div>
|
||||
|
||||
<div class="form-text">
|
||||
<span style="color: red;"><sup>*</sup></span>{{ $t("Required") }}
|
||||
</div>
|
||||
</template>
|
|
@ -26,6 +26,7 @@ import SerwerSMS from "./SerwerSMS.vue";
|
|||
import Stackfield from './Stackfield.vue';
|
||||
import WeCom from "./WeCom.vue";
|
||||
import GoogleChat from "./GoogleChat.vue";
|
||||
import Gorush from "./Gorush.vue";
|
||||
|
||||
/**
|
||||
* Manage all notification form.
|
||||
|
@ -60,7 +61,8 @@ const NotificationFormList = {
|
|||
"serwersms": SerwerSMS,
|
||||
"stackfield": Stackfield,
|
||||
"WeCom": WeCom,
|
||||
"GoogleChat": GoogleChat
|
||||
"GoogleChat": GoogleChat,
|
||||
"gorush": Gorush
|
||||
};
|
||||
|
||||
export default NotificationFormList;
|
||||
|
|
|
@ -361,4 +361,5 @@ export default {
|
|||
smtpDkimHashAlgo: "Hash Algorithm (Optional)",
|
||||
smtpDkimheaderFieldNames: "Header Keys to sign (Optional)",
|
||||
smtpDkimskipFields: "Header Keys not to sign (Optional)",
|
||||
gorush: "Gorush",
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue