Skip to content

Commit cd6dc14

Browse files
feat: add notification provider Notifery (#5832)
Co-authored-by: Frank Elsinga <frank@elsinga.de>
1 parent 2b3f49a commit cd6dc14

File tree

5 files changed

+108
-1
lines changed

5 files changed

+108
-1
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
const { getMonitorRelativeURL, UP } = require("../../src/util");
2+
const { setting } = require("../util-server");
3+
const NotificationProvider = require("./notification-provider");
4+
const axios = require("axios");
5+
6+
class Notifery extends NotificationProvider {
7+
name = "notifery";
8+
9+
/**
10+
* @inheritdoc
11+
*/
12+
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
13+
const okMsg = "Sent Successfully.";
14+
const url = "https://api.notifery.com/event";
15+
16+
let data = {
17+
title: notification.notiferyTitle || "Uptime Kuma Alert",
18+
message: msg,
19+
};
20+
21+
if (notification.notiferyGroup) {
22+
data.group = notification.notiferyGroup;
23+
}
24+
25+
// Link to the monitor
26+
const baseURL = await setting("primaryBaseURL");
27+
if (baseURL && monitorJSON) {
28+
data.message += `\n\nMonitor: ${baseURL}${getMonitorRelativeURL(monitorJSON.id)}`;
29+
}
30+
31+
if (heartbeatJSON) {
32+
data.code = heartbeatJSON.status === UP ? 0 : 1;
33+
34+
if (heartbeatJSON.ping) {
35+
data.duration = heartbeatJSON.ping;
36+
}
37+
}
38+
39+
try {
40+
const headers = {
41+
"Content-Type": "application/json",
42+
"x-api-key": notification.notiferyApiKey,
43+
};
44+
45+
await axios.post(url, data, { headers });
46+
return okMsg;
47+
} catch (error) {
48+
this.throwGeneralAxiosError(error);
49+
}
50+
}
51+
}
52+
53+
module.exports = Notifery;

server/notification.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const DingDing = require("./notification-providers/dingding");
1313
const Discord = require("./notification-providers/discord");
1414
const Elks = require("./notification-providers/46elks");
1515
const Feishu = require("./notification-providers/feishu");
16+
const Notifery = require("./notification-providers/notifery");
1617
const FreeMobile = require("./notification-providers/freemobile");
1718
const GoogleChat = require("./notification-providers/google-chat");
1819
const Gorush = require("./notification-providers/gorush");
@@ -169,6 +170,7 @@ class Notification {
169170
new YZJ(),
170171
new SMSPlanet(),
171172
new SpugPush(),
173+
new Notifery(),
172174
];
173175
for (let item of list) {
174176
if (! item.name) {

src/components/NotificationDialog.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ export default {
168168
"waha": "WhatsApp (WAHA)",
169169
"gtxmessaging": "GtxMessaging",
170170
"Cellsynt": "Cellsynt",
171-
"SendGrid": "SendGrid"
171+
"SendGrid": "SendGrid",
172+
"notifery": "Notifery"
172173
};
173174
174175
// Put notifications here if it's not supported in most regions or its documentation is not in English
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<template>
2+
<div class="mb-3">
3+
<label for="notifery-api-key" class="form-label">{{
4+
$t("API Key")
5+
}}</label>
6+
<HiddenInput
7+
id="notifery-api-key"
8+
v-model="$parent.notification.notiferyApiKey"
9+
:required="true"
10+
autocomplete="new-password"
11+
></HiddenInput>
12+
</div>
13+
14+
<div class="mb-3">
15+
<label for="notifery-title" class="form-label">{{ $t("Title") }}</label>
16+
<input
17+
id="notifery-title"
18+
v-model="$parent.notification.notiferyTitle"
19+
type="text"
20+
class="form-control"
21+
placeholder="Uptime Kuma Alert"
22+
/>
23+
</div>
24+
25+
<div class="mb-3">
26+
<label for="notifery-group" class="form-label">{{ $t("Group") }}</label>
27+
<input
28+
id="notifery-group"
29+
v-model="$parent.notification.notiferyGroup"
30+
type="text"
31+
class="form-control"
32+
:placeholder="$t('Optional')"
33+
/>
34+
</div>
35+
36+
<i18n-t tag="p" keypath="More info on:" style="margin-top: 8px;">
37+
<a href="https://docs.notifery.com/api/event/" target="_blank">https://docs.notifery.com/api/event/</a>
38+
</i18n-t>
39+
</template>
40+
41+
<script>
42+
import HiddenInput from "../HiddenInput.vue";
43+
44+
export default {
45+
components: {
46+
HiddenInput,
47+
},
48+
};
49+
</script>

src/components/notifications/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import AliyunSMS from "./AliyunSms.vue";
44
import Apprise from "./Apprise.vue";
55
import Bark from "./Bark.vue";
66
import Bitrix24 from "./Bitrix24.vue";
7+
import Notifery from "./Notifery.vue";
78
import ClickSendSMS from "./ClickSendSMS.vue";
89
import CallMeBot from "./CallMeBot.vue";
910
import SMSC from "./SMSC.vue";
@@ -149,6 +150,7 @@ const NotificationFormList = {
149150
"ZohoCliq": ZohoCliq,
150151
"SevenIO": SevenIO,
151152
"whapi": Whapi,
153+
"notifery": Notifery,
152154
"waha": WAHA,
153155
"gtxmessaging": GtxMessaging,
154156
"Cellsynt": Cellsynt,

0 commit comments

Comments
 (0)