-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
@@ -36,5 +128,16 @@ export default {
components: {
HiddenInput,
},
+ mounted() {
+ if (!this.$parent.notification.smseagleApiType) {
+ this.$parent.notification.smseagleApiType = "smseagle-apiv1";
+ }
+ if (!this.$parent.notification.smseagleMsgType) {
+ this.$parent.notification.smseagleMsgType = "smseagle-sms";
+ }
+ if (!this.$parent.notification.smseagleRecipientType) {
+ this.$parent.notification.smseagleRecipientType = "smseagle-to";
+ }
+ }
};
diff --git a/src/lang/en.json b/src/lang/en.json
index b53fa1350..772820c59 100644
--- a/src/lang/en.json
+++ b/src/lang/en.json
@@ -757,12 +757,26 @@
"smseagleTo": "Phone number(s)",
"smseagleGroup": "Phonebook group name(s)",
"smseagleContact": "Phonebook contact name(s)",
+ "smseagleGroupV2": "Phonebook group ID(s)",
+ "smseagleContactV2": "Phonebook contact ID(s)",
"smseagleRecipientType": "Recipient type",
"smseagleRecipient": "Recipient(s) (multiple must be separated with comma)",
"smseagleToken": "API Access token",
"smseagleUrl": "Your SMSEagle device URL",
- "smseagleEncoding": "Send as Unicode",
- "smseaglePriority": "Message priority (0-9, default = 0)",
+ "smseagleEncoding": "Send as Unicode (default=GSM-7)",
+ "smseaglePriority": "Message priority (0-9, highest priority = 9)",
+ "smseagleMsgType": "Message type",
+ "smseagleMsgSms": "Sms message (default)",
+ "smseagleMsgRing": "Ring call",
+ "smseagleMsgTts": "Text-to-speech call",
+ "smseagleMsgTtsAdvanced": "Text-to-speech Advanced call",
+ "smseagleDuration": "Duration (in seconds)",
+ "smseagleTtsModel": "Text-to-speech model ID",
+ "smseagleApiType": "API version",
+ "smseagleApiv1": "APIv1 (for existing projects and backward compatibility)",
+ "smseagleApiv2": "APIv2 (recommended for new integrations)",
+ "smseagleDocs": "Check documentation or APIv2 availability: {0}",
+ "smseagleComma": "Multiple must be separated with comma",
"smspartnerApiurl": "You can find your API key in your dashboard at {0}",
"smspartnerPhoneNumber": "Phone number(s)",
"smspartnerPhoneNumberHelptext": "The number must be in the international format {0}, {1}. Multiple numbers must be separated by {2}",
From 83963305524255bcdbbf178e9c44e8d61dd093e7 Mon Sep 17 00:00:00 2001
From: Pargorn Ruasijan
Date: Sun, 27 Apr 2025 23:48:05 +0700
Subject: [PATCH 17/17] Add OneChat notification provider (#5546)
Co-authored-by: Frank Elsinga
---
server/notification-providers/onechat.js | 73 ++++++++++++++++++++++++
server/notification.js | 2 +
src/components/NotificationDialog.vue | 1 +
src/components/notifications/OneChat.vue | 64 +++++++++++++++++++++
src/components/notifications/index.js | 2 +
src/lang/en.json | 3 +
6 files changed, 145 insertions(+)
create mode 100644 server/notification-providers/onechat.js
create mode 100644 src/components/notifications/OneChat.vue
diff --git a/server/notification-providers/onechat.js b/server/notification-providers/onechat.js
new file mode 100644
index 000000000..2d6ea1d5b
--- /dev/null
+++ b/server/notification-providers/onechat.js
@@ -0,0 +1,73 @@
+const NotificationProvider = require("./notification-provider");
+const axios = require("axios");
+const { DOWN, UP } = require("../../src/util");
+
+class OneChat extends NotificationProvider {
+ name = "OneChat";
+
+ /**
+ * @inheritdoc
+ */
+ async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
+ const okMsg = "Sent Successfully.";
+ const url = "https://chat-api.one.th/message/api/v1/push_message";
+
+ try {
+ const config = {
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: "Bearer " + notification.accessToken,
+ },
+ };
+ if (heartbeatJSON == null) {
+ const testMessage = {
+ to: notification.recieverId,
+ bot_id: notification.botId,
+ type: "text",
+ message: "Test Successful!",
+ };
+ await axios.post(url, testMessage, config);
+ } else if (heartbeatJSON["status"] === DOWN) {
+ const downMessage = {
+ to: notification.recieverId,
+ bot_id: notification.botId,
+ type: "text",
+ message:
+ `UptimeKuma Alert:
+[🔴 Down]
+Name: ${monitorJSON["name"]}
+${heartbeatJSON["msg"]}
+Time (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`,
+ };
+ await axios.post(url, downMessage, config);
+ } else if (heartbeatJSON["status"] === UP) {
+ const upMessage = {
+ to: notification.recieverId,
+ bot_id: notification.botId,
+ type: "text",
+ message:
+ `UptimeKuma Alert:
+[🟢 Up]
+Name: ${monitorJSON["name"]}
+${heartbeatJSON["msg"]}
+Time (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`,
+ };
+ await axios.post(url, upMessage, config);
+ }
+
+ return okMsg;
+ } catch (error) {
+ // Handle errors and throw a descriptive message
+ if (error.response) {
+ const errorMessage =
+ error.response.data?.message ||
+ "Unknown API error occurred.";
+ throw new Error(`OneChat API Error: ${errorMessage}`);
+ } else {
+ this.throwGeneralAxiosError(error);
+ }
+ }
+ }
+}
+
+module.exports = OneChat;
diff --git a/server/notification.js b/server/notification.js
index 8682e6f5c..b3f745854 100644
--- a/server/notification.js
+++ b/server/notification.js
@@ -30,6 +30,7 @@ const Mattermost = require("./notification-providers/mattermost");
const Nostr = require("./notification-providers/nostr");
const Ntfy = require("./notification-providers/ntfy");
const Octopush = require("./notification-providers/octopush");
+const OneChat = require("./notification-providers/onechat");
const OneBot = require("./notification-providers/onebot");
const Opsgenie = require("./notification-providers/opsgenie");
const PagerDuty = require("./notification-providers/pagerduty");
@@ -121,6 +122,7 @@ class Notification {
new Nostr(),
new Ntfy(),
new Octopush(),
+ new OneChat(),
new OneBot(),
new Onesender(),
new Opsgenie(),
diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue
index 3ea3e23d4..1b15616aa 100644
--- a/src/components/NotificationDialog.vue
+++ b/src/components/NotificationDialog.vue
@@ -135,6 +135,7 @@ export default {
"nostr": "Nostr",
"ntfy": "Ntfy",
"octopush": "Octopush",
+ "OneChat": "OneChat",
"OneBot": "OneBot",
"Onesender": "Onesender",
"Opsgenie": "Opsgenie",
diff --git a/src/components/notifications/OneChat.vue b/src/components/notifications/OneChat.vue
new file mode 100644
index 000000000..b954d338b
--- /dev/null
+++ b/src/components/notifications/OneChat.vue
@@ -0,0 +1,64 @@
+
+
+
+
+
+
+
+
+
{{ $t("OneChatAccessToken") }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js
index ae28ff03a..70e7d336d 100644
--- a/src/components/notifications/index.js
+++ b/src/components/notifications/index.js
@@ -29,6 +29,7 @@ import Mattermost from "./Mattermost.vue";
import Nostr from "./Nostr.vue";
import Ntfy from "./Ntfy.vue";
import Octopush from "./Octopush.vue";
+import OneChat from "./OneChat.vue";
import OneBot from "./OneBot.vue";
import Onesender from "./Onesender.vue";
import Opsgenie from "./Opsgenie.vue";
@@ -108,6 +109,7 @@ const NotificationFormList = {
"nostr": Nostr,
"ntfy": Ntfy,
"octopush": Octopush,
+ "OneChat": OneChat,
"OneBot": OneBot,
"Onesender": Onesender,
"Opsgenie": Opsgenie,
diff --git a/src/lang/en.json b/src/lang/en.json
index 772820c59..b089478f8 100644
--- a/src/lang/en.json
+++ b/src/lang/en.json
@@ -1071,6 +1071,9 @@
"rabbitmqHelpText": "To use the monitor, you will need to enable the Management Plugin in your RabbitMQ setup. For more information, please consult the {rabitmq_documentation}.",
"SendGrid API Key": "SendGrid API Key",
"Separate multiple email addresses with commas": "Separate multiple email addresses with commas",
+ "OneChatAccessToken": "OneChat Access Token",
+ "OneChatUserIdOrGroupId": "OneChat User ID or Group ID",
+ "OneChatBotId": "OneChat Bot ID",
"wahaSession": "Session",
"wahaChatId": "Chat ID (Phone Number / Contact ID / Group ID)",
"wayToGetWahaApiUrl": "Your WAHA Instance URL.",