Merge branch 'louislam:master' into master

This commit is contained in:
Julian Speckmann 2025-12-31 17:53:06 +01:00 committed by GitHub
commit b935b1650f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 32 additions and 68 deletions

View 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.
};

View File

@ -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 ]);

View File

@ -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;

View File

@ -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(),

View File

@ -1,6 +1,6 @@
html[lang='fa'] {
#app {
font-family: 'IRANSans', 'Iranian Sans','B Nazanin', 'Tahoma', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, segoe ui, Roboto, helvetica neue, Arial, noto sans, sans-serif, apple color emoji, segoe ui emoji, segoe ui symbol, noto color emoji;
font-family: 'Vazirmatn', 'IRANSans', 'Iranian Sans','B Nazanin', 'Tahoma', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, segoe ui, Roboto, helvetica neue, Arial, noto sans, sans-serif, apple color emoji, segoe ui emoji, segoe ui symbol, noto color emoji;
}
}

View File

@ -129,7 +129,6 @@ export default {
"Keep": "Keep",
"Kook": "Kook",
"line": "LINE Messenger",
"LineNotify": "LINE Notify",
"lunasea": "LunaSea",
"matrix": "Matrix",
"mattermost": "Mattermost",

View File

@ -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>

View File

@ -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,