diff --git a/db/knex_migrations/2025-12-29-0000-remove-line-notify.js b/db/knex_migrations/2025-12-29-0000-remove-line-notify.js new file mode 100644 index 000000000..2011ce852 --- /dev/null +++ b/db/knex_migrations/2025-12-29-0000-remove-line-notify.js @@ -0,0 +1,30 @@ +exports.up = async function (knex) { + const notifications = await knex("notification").select("id", "config"); + const lineNotifyIDs = []; + + for (const { id, config } of notifications) { + try { + const parsedConfig = JSON.parse(config || "{}"); + const type = typeof parsedConfig.type === "string" ? parsedConfig.type.toLowerCase() : ""; + + if (type === "linenotify" || type === "line-notify") { + lineNotifyIDs.push(id); + } + } catch (error) { + // Ignore invalid JSON blobs here; they are handled elsewhere in the app. + } + } + + if (lineNotifyIDs.length === 0) { + return; + } + + await knex.transaction(async (trx) => { + await trx("monitor_notification").whereIn("notification_id", lineNotifyIDs).del(); + await trx("notification").whereIn("id", lineNotifyIDs).del(); + }); +}; + +exports.down = async function () { + // Removal of LINE Notify configs is not reversible. +}; diff --git a/server/monitor-types/websocket-upgrade.js b/server/monitor-types/websocket-upgrade.js index c53225306..762e8df3b 100644 --- a/server/monitor-types/websocket-upgrade.js +++ b/server/monitor-types/websocket-upgrade.js @@ -39,6 +39,7 @@ class WebSocketMonitorType extends MonitorType { // Give user the choice to ignore Sec-WebSocket-Accept header if (monitor.wsIgnoreSecWebsocketAcceptHeader && error.message === "Invalid Sec-WebSocket-Accept header") { resolve([ "101 - OK", 1000 ]); + return; } // Upgrade failed, return message to user resolve([ error.message, error.code ]); diff --git a/server/notification-providers/linenotify.js b/server/notification-providers/linenotify.js deleted file mode 100644 index 30b2e800d..000000000 --- a/server/notification-providers/linenotify.js +++ /dev/null @@ -1,53 +0,0 @@ -const NotificationProvider = require("./notification-provider"); -const axios = require("axios"); -const qs = require("qs"); -const { DOWN, UP } = require("../../src/util"); - -class LineNotify extends NotificationProvider { - name = "LineNotify"; - - /** - * @inheritdoc - */ - async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { - const okMsg = "Sent Successfully."; - const url = "https://notify-api.line.me/api/notify"; - - try { - let config = { - headers: { - "Content-Type": "application/x-www-form-urlencoded", - "Authorization": "Bearer " + notification.lineNotifyAccessToken - } - }; - config = this.getAxiosConfigWithProxy(config); - if (heartbeatJSON == null) { - let testMessage = { - "message": msg, - }; - await axios.post(url, qs.stringify(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"]}` - }; - await axios.post(url, qs.stringify(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"]}` - }; - await axios.post(url, qs.stringify(upMessage), config); - } - return okMsg; - } catch (error) { - this.throwGeneralAxiosError(error); - } - } -} - -module.exports = LineNotify; diff --git a/server/notification.js b/server/notification.js index e25bca08b..555f10cc1 100644 --- a/server/notification.js +++ b/server/notification.js @@ -25,7 +25,6 @@ const HeiiOnCall = require("./notification-providers/heii-oncall"); const Keep = require("./notification-providers/keep"); const Kook = require("./notification-providers/kook"); const Line = require("./notification-providers/line"); -const LineNotify = require("./notification-providers/linenotify"); const LunaSea = require("./notification-providers/lunasea"); const Matrix = require("./notification-providers/matrix"); const Mattermost = require("./notification-providers/mattermost"); @@ -124,7 +123,6 @@ class Notification { new Keep(), new Kook(), new Line(), - new LineNotify(), new LunaSea(), new Matrix(), new Mattermost(), diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index 98df20abb..9ed38e9cb 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -129,7 +129,6 @@ export default { "Keep": "Keep", "Kook": "Kook", "line": "LINE Messenger", - "LineNotify": "LINE Notify", "lunasea": "LunaSea", "matrix": "Matrix", "mattermost": "Mattermost", diff --git a/src/components/notifications/LineNotify.vue b/src/components/notifications/LineNotify.vue deleted file mode 100644 index 0f6897f46..000000000 --- a/src/components/notifications/LineNotify.vue +++ /dev/null @@ -1,9 +0,0 @@ - diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js index 9bc4f050d..b0fa68342 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -24,7 +24,6 @@ import HeiiOnCall from "./HeiiOnCall.vue"; import Keep from "./Keep.vue"; import Kook from "./Kook.vue"; import Line from "./Line.vue"; -import LineNotify from "./LineNotify.vue"; import LunaSea from "./LunaSea.vue"; import Matrix from "./Matrix.vue"; import Mattermost from "./Mattermost.vue"; @@ -112,7 +111,6 @@ const NotificationFormList = { "Keep": Keep, "Kook": Kook, "line": Line, - "LineNotify": LineNotify, "lunasea": LunaSea, "matrix": Matrix, "mattermost": Mattermost,