remove: drop LINE Notify integration (#6088)
This commit is contained in:
commit
271a2d3b35
30
db/knex_migrations/2025-12-29-0000-remove-line-notify.js
Normal file
30
db/knex_migrations/2025-12-29-0000-remove-line-notify.js
Normal file
@ -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.
|
||||
};
|
||||
@ -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 ]);
|
||||
|
||||
@ -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;
|
||||
@ -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(),
|
||||
|
||||
@ -129,7 +129,6 @@ export default {
|
||||
"Keep": "Keep",
|
||||
"Kook": "Kook",
|
||||
"line": "LINE Messenger",
|
||||
"LineNotify": "LINE Notify",
|
||||
"lunasea": "LunaSea",
|
||||
"matrix": "Matrix",
|
||||
"mattermost": "Mattermost",
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
<template>
|
||||
<div class="mb-3">
|
||||
<label for="line-notify-access-token" class="form-label">{{ $t("Access Token") }}</label>
|
||||
<input id="line-notify-access-token" v-model="$parent.notification.lineNotifyAccessToken" type="text" class="form-control" :required="true">
|
||||
</div>
|
||||
<i18n-t tag="div" keypath="wayToGetLineNotifyToken" class="form-text" style="margin-top: 8px;">
|
||||
<a href="https://notify-bot.line.me/" target="_blank">https://notify-bot.line.me/</a>
|
||||
</i18n-t>
|
||||
</template>
|
||||
@ -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,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user