mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-23 23:04:04 +00:00
add ntfy support
ref https://github.com/louislam/uptime-kuma/issues/1622
This commit is contained in:
parent
6ae2a48584
commit
71f031c14e
4 changed files with 67 additions and 0 deletions
29
server/notification-providers/ntfy.js
Normal file
29
server/notification-providers/ntfy.js
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
const NotificationProvider = require("./notification-provider");
|
||||||
|
const axios = require("axios");
|
||||||
|
|
||||||
|
class Ntfy extends NotificationProvider {
|
||||||
|
|
||||||
|
name = "ntfy";
|
||||||
|
|
||||||
|
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
||||||
|
let okMsg = "Sent Successfully.";
|
||||||
|
try {
|
||||||
|
if (notification.ntfyserverurl && notification.ntfyserverurl.endsWith("/")) {
|
||||||
|
notification.ntfyserverurl = notification.ntfyserverurl.slice(0, -1);
|
||||||
|
}
|
||||||
|
await axios.post(`${notification.ntfyserverurl}`, {
|
||||||
|
"topic": notification.ntfytopic,
|
||||||
|
"message": msg,
|
||||||
|
"priority": notification.ntfyPriority || 4,
|
||||||
|
"title": "Uptime-Kuma",
|
||||||
|
})
|
||||||
|
|
||||||
|
return okMsg;
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
this.throwGeneralAxiosError(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = Ntfy;
|
|
@ -2,6 +2,7 @@ const { R } = require("redbean-node");
|
||||||
const Apprise = require("./notification-providers/apprise");
|
const Apprise = require("./notification-providers/apprise");
|
||||||
const Discord = require("./notification-providers/discord");
|
const Discord = require("./notification-providers/discord");
|
||||||
const Gotify = require("./notification-providers/gotify");
|
const Gotify = require("./notification-providers/gotify");
|
||||||
|
const Ntfy = require("./notification-providers/ntfy");
|
||||||
const Line = require("./notification-providers/line");
|
const Line = require("./notification-providers/line");
|
||||||
const LunaSea = require("./notification-providers/lunasea");
|
const LunaSea = require("./notification-providers/lunasea");
|
||||||
const Mattermost = require("./notification-providers/mattermost");
|
const Mattermost = require("./notification-providers/mattermost");
|
||||||
|
@ -51,6 +52,7 @@ class Notification {
|
||||||
new Discord(),
|
new Discord(),
|
||||||
new Teams(),
|
new Teams(),
|
||||||
new Gotify(),
|
new Gotify(),
|
||||||
|
new Ntfy(),
|
||||||
new Line(),
|
new Line(),
|
||||||
new LunaSea(),
|
new LunaSea(),
|
||||||
new Feishu(),
|
new Feishu(),
|
||||||
|
|
34
src/components/notifications/Ntfy.vue
Normal file
34
src/components/notifications/Ntfy.vue
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
<template>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="ntfy-ntfytopic" class="form-label">ntfytopic</label>
|
||||||
|
<div class="input-group mb-3">
|
||||||
|
<input id="ntfy-ntfytopic" v-model="$parent.notification.ntfytopic" type="text" class="form-control" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="ntfy-server-url" class="form-label">{{ $t("Server URL") }}</label>
|
||||||
|
<div class="input-group mb-3">
|
||||||
|
<input id="ntfy-server-url" v-model="$parent.notification.ntfyserverurl" type="text" class="form-control" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="ntfy-priority" class="form-label">{{ $t("Priority") }}</label>
|
||||||
|
<input id="ntfy-priority" v-model="$parent.notification.ntfyPriority" type="number" class="form-control" required min="0" max="10" step="1">
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import HiddenInput from "../HiddenInput.vue";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
HiddenInput,
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
if (typeof this.$parent.notification.ntfyPriority === "undefined") {
|
||||||
|
this.$parent.notification.ntfyPriority = 4;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
|
@ -4,6 +4,7 @@ import Discord from "./Discord.vue";
|
||||||
import Webhook from "./Webhook.vue";
|
import Webhook from "./Webhook.vue";
|
||||||
import Signal from "./Signal.vue";
|
import Signal from "./Signal.vue";
|
||||||
import Gotify from "./Gotify.vue";
|
import Gotify from "./Gotify.vue";
|
||||||
|
import Ntfy from "./Ntfy.vue";
|
||||||
import Slack from "./Slack.vue";
|
import Slack from "./Slack.vue";
|
||||||
import RocketChat from "./RocketChat.vue";
|
import RocketChat from "./RocketChat.vue";
|
||||||
import Teams from "./Teams.vue";
|
import Teams from "./Teams.vue";
|
||||||
|
@ -45,6 +46,7 @@ const NotificationFormList = {
|
||||||
"teams": Teams,
|
"teams": Teams,
|
||||||
"signal": Signal,
|
"signal": Signal,
|
||||||
"gotify": Gotify,
|
"gotify": Gotify,
|
||||||
|
"ntfy": Ntfy,
|
||||||
"slack": Slack,
|
"slack": Slack,
|
||||||
"rocket.chat": RocketChat,
|
"rocket.chat": RocketChat,
|
||||||
"pushover": Pushover,
|
"pushover": Pushover,
|
||||||
|
|
Loading…
Reference in a new issue