diff --git a/server/notification-providers/linenotify.js b/server/notification-providers/linenotify.js
index 2622e3f1c..3918dc59e 100644
--- a/server/notification-providers/linenotify.js
+++ b/server/notification-providers/linenotify.js
@@ -1,6 +1,5 @@
const NotificationProvider = require("./notification-provider");
const axios = require("axios");
-const qs = require("qs");
const { DOWN, UP } = require("../../src/util");
class LineNotify extends NotificationProvider {
@@ -11,36 +10,55 @@ class LineNotify extends NotificationProvider {
*/
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
const okMsg = "Sent Successfully.";
- const url = "https://notify-api.line.me/api/notify";
+ const url = "https://api.line.me/v2/bot/message/broadcast";
try {
- let config = {
+ const config = {
headers: {
- "Content-Type": "application/x-www-form-urlencoded",
- "Authorization": "Bearer " + notification.lineNotifyAccessToken
- }
+ "Content-Type": "application/json",
+ Authorization:
+ "Bearer " + notification.lineNotifyAccessToken,
+ },
};
- if (heartbeatJSON == null) {
- let testMessage = {
- "message": msg,
+
+ if (!heartbeatJSON) {
+ const testMessage = {
+ messages: [
+ {
+ type: "text",
+ text: msg,
+ },
+ ],
};
- await axios.post(url, qs.stringify(testMessage), config);
+ await axios.post(url, testMessage, config);
} else if (heartbeatJSON["status"] === DOWN) {
- let downMessage = {
- "message": "\n[🔴 Down]\n" +
- "Name: " + monitorJSON["name"] + " \n" +
- heartbeatJSON["msg"] + "\n" +
- `Time (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`
+ const downMessage = {
+ messages: [
+ {
+ type: "text",
+ text:
+ "🔴 [Down]\n" +
+ `Name: ${monitorJSON["name"]}\n` +
+ `${heartbeatJSON["msg"]}\n` +
+ `Time (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`,
+ },
+ ],
};
- await axios.post(url, qs.stringify(downMessage), config);
+ await axios.post(url, downMessage, config);
} else if (heartbeatJSON["status"] === UP) {
- let upMessage = {
- "message": "\n[✅ Up]\n" +
- "Name: " + monitorJSON["name"] + " \n" +
- heartbeatJSON["msg"] + "\n" +
- `Time (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`
+ const upMessage = {
+ messages: [
+ {
+ type: "text",
+ text:
+ "✅ [Up]\n" +
+ `Name: ${monitorJSON["name"]}\n` +
+ `${heartbeatJSON["msg"]}\n` +
+ `Time (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`,
+ },
+ ],
};
- await axios.post(url, qs.stringify(upMessage), config);
+ await axios.post(url, upMessage, config);
}
return okMsg;
} catch (error) {
diff --git a/src/components/notifications/LineNotify.vue b/src/components/notifications/LineNotify.vue
index 0f6897f46..98478e735 100644
--- a/src/components/notifications/LineNotify.vue
+++ b/src/components/notifications/LineNotify.vue
@@ -4,6 +4,6 @@
- https://notify-bot.line.me/
+ {{ $t("Line Developers Console") }}
diff --git a/src/lang/en.json b/src/lang/en.json
index b6449371b..cdd8578f0 100644
--- a/src/lang/en.json
+++ b/src/lang/en.json
@@ -440,7 +440,7 @@
"chatIDNotFound": "Chat ID is not found; please send a message to this bot first",
"disableCloudflaredNoAuthMsg": "You are in No Auth mode, a password is not required.",
"trustProxyDescription": "Trust 'X-Forwarded-*' headers. If you want to get the correct client IP and your Uptime Kuma is behind a proxy such as Nginx or Apache, you should enable this.",
- "wayToGetLineNotifyToken": "You can get an access token from {0}",
+ "wayToGetLineNotifyToken": "First access the {0}, create a provider and channel (Messaging API), then you can get the channel access token",
"Examples": "Examples",
"Home Assistant URL": "Home Assistant URL",
"Long-Lived Access Token": "Long-Lived Access Token",